This commit is contained in:
@@ -8,163 +8,169 @@
|
||||
/*global $, app */
|
||||
|
||||
app.customerSiteEdit = (function () {
|
||||
'use strict';
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var
|
||||
stateMap = {},
|
||||
onSave, onDelete, configModule, initModule;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
"use strict";
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var stateMap = {},
|
||||
onSave,
|
||||
onDelete,
|
||||
configModule,
|
||||
initModule;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
|
||||
//------------------- BEGIN UTILITY METHODS ------------------
|
||||
//-------------------- END UTILITY METHODS -------------------
|
||||
//------------------- BEGIN UTILITY METHODS ------------------
|
||||
//-------------------- END UTILITY METHODS -------------------
|
||||
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
|
||||
onSave = function (event) {
|
||||
onSave = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
//get form data
|
||||
var formData = $("form").serializeArray({
|
||||
checkboxesAsBools: true
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
$.gevent.publish('app-clear-error');
|
||||
//get form data
|
||||
var formData = $("form").serializeArray({
|
||||
checkboxesAsBools: true
|
||||
});
|
||||
var submitData = app.utilB.objectifyFormDataArray(formData);
|
||||
|
||||
var submitData = app.utilB.objectifyFormDataArray(formData);
|
||||
//is this a new record?
|
||||
if (stateMap.id != "new") {
|
||||
//put id into the form data
|
||||
submitData.id = stateMap.id;
|
||||
|
||||
|
||||
//is this a new record?
|
||||
if (stateMap.id != 'new') {
|
||||
//put id into the form data
|
||||
submitData.id = stateMap.id;
|
||||
|
||||
app.api.update('site', submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error',res.msg);
|
||||
}
|
||||
});
|
||||
app.api.update("site", submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//create new record
|
||||
app.api.create("site", submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
//create new record
|
||||
app.api.create('site', submitData, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error',res.msg);
|
||||
} else {
|
||||
page('#!/customerSiteEdit/' + res.id + '/' + stateMap.context.params.cust_id);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
page(
|
||||
"#!/customerSiteEdit/" +
|
||||
res.id +
|
||||
"/" +
|
||||
stateMap.context.params.cust_id
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return false; //prevent default
|
||||
};
|
||||
});
|
||||
}
|
||||
return false; //prevent default
|
||||
};
|
||||
|
||||
//ONDELETE
|
||||
//
|
||||
onDelete = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
|
||||
//ONDELETE
|
||||
//
|
||||
onDelete = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish('app-clear-error');
|
||||
|
||||
var r = confirm("Are you sure you want to delete this record?");
|
||||
if (r == true) {
|
||||
//--------------------------------------------
|
||||
//==== DELETE THE site and it's children ====
|
||||
app.api.remove('site/' + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error',res.msg);
|
||||
} else {
|
||||
//deleted, return to customers list
|
||||
page('#!/customerSites/' + stateMap.context.params.cust_id);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//--------------------
|
||||
|
||||
var r = confirm("Are you sure you want to delete this record?");
|
||||
if (r == true) {
|
||||
//--------------------------------------------
|
||||
//==== DELETE THE site and it's children ====
|
||||
app.api.remove("site/" + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
return false;
|
||||
//deleted, return to customers list
|
||||
page("#!/customerSites/" + stateMap.context.params.cust_id);
|
||||
return false;
|
||||
}
|
||||
return false; //prevent default?
|
||||
};
|
||||
});
|
||||
//--------------------
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
}
|
||||
};
|
||||
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === "undefined") {
|
||||
$container = $("#app-shell-main-content");
|
||||
}
|
||||
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
$container.html(Handlebars.templates["app.customerSiteEdit"]({}));
|
||||
var title = "Site";
|
||||
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
}
|
||||
};
|
||||
if (stateMap.context.params.cust_id) {
|
||||
//Append customer id as a hidden form field for referential integrity
|
||||
$("<input />")
|
||||
.attr("type", "hidden")
|
||||
.attr("name", "customerId")
|
||||
.attr("value", stateMap.context.params.cust_id)
|
||||
.appendTo("#frm");
|
||||
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === 'undefined') {
|
||||
$container = $('#app-shell-main-content');
|
||||
}
|
||||
|
||||
$container.html(Handlebars.templates['app.customerSiteEdit']({}));
|
||||
var title = "Site";
|
||||
|
||||
if (stateMap.context.params.cust_id) {
|
||||
//Append customer id as a hidden form field for referential integrity
|
||||
$('<input />').attr('type', 'hidden')
|
||||
.attr('name', "customerId")
|
||||
.attr('value', stateMap.context.params.cust_id)
|
||||
.appendTo('#frm');
|
||||
|
||||
//fetch existing record
|
||||
app.api.get('customer/' + stateMap.context.params.cust_id + '/name', function (res) {
|
||||
//fetch existing record
|
||||
app.api.get(
|
||||
"customer/" + stateMap.context.params.cust_id + "/name",
|
||||
function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
title = "Site - " + res.name;
|
||||
if (stateMap.id != "new") {
|
||||
//fetch existing record
|
||||
app.api.get("site/" + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error',res.msg);
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
title = 'Site - ' + res.name;
|
||||
if (stateMap.id != 'new') {
|
||||
//fetch existing record
|
||||
app.api.get('site/' + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error',res.msg);
|
||||
} else {
|
||||
//fill out form
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//it's a new record, set default
|
||||
$("#legacyV7").val(true);
|
||||
$("#dbId").val("v7_no_dbid");
|
||||
}
|
||||
//fill out form
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//it's a new record, set default
|
||||
$("#legacyV7").prop("checked", true);
|
||||
$("#dbId").val("v7_no_dbid");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// bind actions
|
||||
$('#btn-save').bind('click', onSave);
|
||||
$('#btn-delete').bind('click', onDelete);
|
||||
// bind actions
|
||||
$("#btn-save").bind("click", onSave);
|
||||
$("#btn-delete").bind("click", onDelete);
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddLink(
|
||||
"customerEdit/" + stateMap.context.params.cust_id,
|
||||
"Customer",
|
||||
"account"
|
||||
);
|
||||
app.nav.contextAddLink(
|
||||
"customerSites/" + stateMap.context.params.cust_id,
|
||||
"Sites",
|
||||
"city"
|
||||
);
|
||||
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddLink("customerEdit/" + stateMap.context.params.cust_id, "Customer", "account");
|
||||
app.nav.contextAddLink("customerSites/" + stateMap.context.params.cust_id, "Sites", "city");
|
||||
if (stateMap.id != "new") {
|
||||
app.nav.contextAddLink("purchases/" + stateMap.id, "Purchases", "basket");
|
||||
}
|
||||
};
|
||||
|
||||
if (stateMap.id != 'new') {
|
||||
app.nav.contextAddLink("purchases/" + stateMap.id, "Purchases", "basket");
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// return public methods
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
}());
|
||||
// return public methods
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
})();
|
||||
|
||||
@@ -19,19 +19,26 @@
|
||||
<input class="form-control" type="text" id="stateProvince" name="stateProvince" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="dbId">Raven database Id</label>
|
||||
<input class="form-control" type="text" id="dbId" name="dbId" value="">
|
||||
<label for="dbType">Database type</label>
|
||||
<input class="form-control" type="text" id="dbType" name="dbType" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label" for="legacyV7">
|
||||
<input class="form-check-input" type="checkbox" name="legacyV7" id="legacyV7">
|
||||
Legacy / AyaNova 7</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="dbId">Raven database Id</label>
|
||||
<input class="form-control" type="text" id="dbId" name="dbId" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label" for="networked">
|
||||
@@ -39,12 +46,7 @@
|
||||
Networked</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="dbType">Database type</label>
|
||||
<input class="form-control" type="text" id="dbType" name="dbType" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{!-- <div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="serverOS">Server OS</label>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user