wip javascript

This commit is contained in:
John Woodlock
2012-07-04 00:13:11 +10:00
parent df30e63559
commit 5e5bb62b81
2 changed files with 76 additions and 43 deletions
+22 -22
View File
@@ -1070,14 +1070,14 @@
<div id="formerrors"></div>
</div>
<fieldset>
<legend><spring:message code="form.legend.office.details"/></legend>
<label for="name"><spring:message code="form.label.office.name"/></label>
<legend>{{=$ctx.doI18N("form.legend.office.details")}}</legend>
<label for="name">{{=$ctx.doI18N("form.label.office.name")}}</label>
<input id="name" name="name" title="" type="text" value="{{=name}}" size="75"/>
{{#if allowedParents.length > 0}}
<label for="parentId"><spring:message code="form.label.office.parent"/></label>
<label for="parentId">{{=$ctx.doI18N("form.label.office.parent")}}</label>
<select id="parentId" name="parentId" title="">
<option value="-1"><spring:message code="option.office.first.choice"/></option>
<option value="-1">{{=$ctx.doI18N("option.office.first.choice")}}</option>
{{#each allowedParents}}
{{#if $ctx.number($parent.parent.data.parentId)===$ctx.number(id)}}
<option value="{{=$ctx.number(id)}}" selected="selected">{{=name}}</option>
@@ -1091,10 +1091,10 @@
{{/if}}
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
<label for="openingDate"><spring:message code="form.label.office.openedon"/></label>
<label for="openingDate">{{=$ctx.doI18N("form.label.office.openedon")}}</label>
<input id="openingDate" name="openingDate" title="" type="text" value="{{=$ctx.globalDate(openingDate)}}" size="75" class="datepickerfield" />
<label for="externalId"><spring:message code="form.label.office.externalid"/></label>
<label for="externalId">{{=$ctx.doI18N("form.label.office.externalid")}}</label>
<input id="externalId" name="externalId" title="" type="text" value="{{=externalId}}" size="75"/>
</fieldset>
</form>
@@ -1104,10 +1104,10 @@
<form id="entityform">
<div id="formerrors"></div>
<fieldset>
<legend><spring:message code="form.legend.loan.product.currency"/></legend>
<legend>{{=$ctx.doI18N("form.legend.loan.product.currency")}}</legend>
<div class="multiselectwidget" style="width:400px;height:125px;">
<label for="notSelectedCurrencies"><spring:message code="form.label.configuration.available.currencies"/></label>
<label for="notSelectedCurrencies">{{=$ctx.doI18N("form.label.configuration.available.currencies")}}</label>
<select id="notSelectedCurrencies" name="notSelectedCurrencies" title="" class="multiselectwidget" multiple="multiple" style="width:400px;height:125px;">
{{#each currencyOptions}}
{{#if $ctx.number($parent.parent.data.code)===code}}
@@ -1117,11 +1117,11 @@
{{/if}}
{{/each}}
</select>
<a href="#" id="add" class="multiselectwidget"><spring:message code="widget.multiselect.button.add"/> &gt;&gt;</a>
<a href="unknown.html" id="addcurrencies" class="multiselectwidget">{{=$ctx.doI18N("widget.multiselect.button.add")}} &gt;&gt;</a>
</div>
<div class="multiselectwidget">
<label for="currencies"><spring:message code="form.label.configuration.allowed.currencies"/></label>
<label for="currencies">{{=$ctx.doI18N("form.label.configuration.allowed.currencies")}}</label>
<select id="currencies" name="currencies" title="" class="multiselectwidget" multiple="multiple" style="width:400px;height:125px;">
{{#each selectedCurrencyOptions}}
{{#if $ctx.number($parent.parent.data.code)===code}}
@@ -1131,7 +1131,7 @@
{{/if}}
{{/each}}
</select>
<a href="#" id="remove" class="multiselectwidget">&lt;&lt; <spring:message code="widget.multiselect.button.remove"/></a>
<a href="unknown.html" id="removecurrencies" class="multiselectwidget">&lt;&lt; {{=$ctx.doI18N("widget.multiselect.button.remove")}}</a>
</div>
</fieldset>
</form>
@@ -1166,40 +1166,40 @@
</script>
<script id="userSettingsTemplate" type="text/x-jquery-tmpl">
<h2><spring:message code="form.label.heading.office"/></h2>
<h2>{{=$ctx.doI18N("form.label.heading.office")}}</h2>
<div class="row">
<span class="rowlabel"><spring:message code="form.label.office"/></span>
<span class="rowlabel">{{=$ctx.doI18N("form.label.office")}}</span>
<span class="rowvalue">{{=officeName}}</span>
</div>
<br/>
<h2><spring:message code="form.label.heading.details"/></h2>
<h2>{{=$ctx.doI18N("form.label.heading.details")}}</h2>
<div class="row">
<span class="rowlabel"><spring:message code="form.label.name"/></span>
<span class="rowlabel">{{=$ctx.doI18N("form.label.name")}}</span>
<span class="rowvalue">{{=firstname}}&nbsp;{{=lastname}}</span>
</div>
<div class="row">
<span class="rowlabel"><spring:message code="form.label.username"/></span>
<span class="rowlabel">{{=$ctx.doI18N("form.label.username")}}</span>
<span class="rowvalue">{{=username}}</span>
</div>
<div class="row">
<span class="rowlabel"><spring:message code="form.label.email"/></span>
<span class="rowlabel">{{=$ctx.doI18N("form.label.email")}}</span>
<span class="rowvalue">{{=email}}</span>
</div>
<div class="row">
<span class="rowlabel">&nbsp;</span>
<span class="rowvalue"><a href="#" id="changedetails"><spring:message code="form.link.changedetails"/></a></span>
<span class="rowvalue"><a href="#" id="changedetails">{{=$ctx.doI18N("form.link.changedetails")}}</a></span>
</div>
<br/>
<h2><spring:message code="form.label.heading.security"/></h2>
<h2>{{=$ctx.doI18N("form.label.heading.security")}}</h2>
<div class="row">
<span class="rowlabel"><spring:message code="form.label.password"/></span>
<span class="rowvalue"><a href="#" id="changepassword"><spring:message code="form.link.changepassword"/></a></span>
<span class="rowlabel">{{=$ctx.doI18N("form.label.password")}}</span>
<span class="rowvalue"><a href="#" id="changepassword">{{=$ctx.doI18N("form.link.changepassword")}}</a></span>
</div>
<br/>
<h2><spring:message code="form.label.heading.roles"/></h2>
<h2>{{=$ctx.doI18N("form.label.heading.roles")}}</h2>
{{#each selectedRoles}}
<div class="row">
<span class="rowlabel">&nbsp;</span>
+54 -21
View File
@@ -107,6 +107,8 @@ function setAddLoanContent(divName) {
function setOrgAdminContent(divName) {
var addLoanProductUrl = "maintainLoanProduct('loanproducts/template', 'loanproducts', 'POST', 'dialog.title.add.loan.product');return false;";
var addOfficeUrl = "maintainOffice('offices/template', 'offices', 'POST', 'dialog.title.add.office');return false;";
var orgCurrenciesUrl = "maintainOrgCurrencies('configurations/currency', 'configurations/currency', 'PUT', 'dialog.title.configuration.currencies');return false;";
var htmlVar = '<div id="inputarea"></div><div id="schedulearea"></div>'
var htmlVar = '<div>';
@@ -117,9 +119,9 @@ function setOrgAdminContent(divName) {
htmlVar += ' | ';
htmlVar += ' <a href="unknown.html" onclick="refreshOfficesView();return false;" id="viewoffices">' + doI18N("administration.link.view.offices") + '</a>';
htmlVar += ' | ';
htmlVar += ' <a href="#" id="addoffice">' + doI18N("administration.link.add.office") + '</a>';
htmlVar += ' <a href="unknown.html" onclick="' + addOfficeUrl + '" id="addoffice">' + doI18N("administration.link.add.office") + '</a>';
htmlVar += ' | ';
htmlVar += ' <a href="#" id="editconfiguration">' + doI18N("administration.link.currency.configuration") + '</a>';
htmlVar += ' <a href="unknown.html" onclick="' + orgCurrenciesUrl + '" id="editconfiguration">' + doI18N("administration.link.currency.configuration") + '</a>';
htmlVar += '</span>';
htmlVar += '</div>';
htmlVar += '<br><br>';
@@ -379,6 +381,10 @@ function jsViewsRegisterHelpers() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (this.name === 'notSelectedCurrencies') {
// do not serialize
} else {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
@@ -386,13 +392,14 @@ function jsViewsRegisterHelpers() {
o[this.name].push(this.value || '');
} else {
if (this.name === 'selectedItems' || this.name === 'notSelectedItems') {
if (this.name === 'selectedItems' || this.name === 'notSelectedItems' || this.name === 'currencies') {
o[this.name] = new Array();
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
}
}
});
return o;
};
@@ -421,11 +428,18 @@ function jsViewsRegisterHelpers() {
$('#notSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#notSelectedCurrencies option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#currencies option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
@@ -446,15 +460,23 @@ function jsViewsRegisterHelpers() {
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('#addcurrencies').click(function() {
return !$('#notSelectedCurrencies option:selected').remove().appendTo('#currencies');
});
$('#removecurrencies').click(function() {
return !$('#currencies option:selected').remove().appendTo('#notSelectedCurrencies');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
@@ -1174,8 +1196,6 @@ function loadILLoan(baseApiUrl, loanId) {
executeAjaxRequest(url, 'GET', "", base64, successFunction, formErrorFunction);
}
function maintainLoanProduct(getUrl, putOrPostUrl, submitType, dialogTitle) {
var templateSelector = "#productFormTemplate";
var width = 800;
@@ -1204,19 +1224,9 @@ function loadILLoan(baseApiUrl, loanId) {
$("a.edit").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("edit", "");
var getUrl = baseApiUrl + 'offices/' + entityId + '?template=true';
var putUrl = baseApiUrl + 'offices/' + entityId;
var templateSelector = "#officeFormTemplate";
var width = 600;
var height = 400;
var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close");
refreshOfficesView();
}
popupDialogWithFormView(getUrl, putUrl, 'PUT', "dialog.title.office.details", templateSelector, width, height, saveSuccessFunction);
var getUrl = 'offices/' + entityId + '?template=true';
var putUrl = 'offices/' + entityId;
maintainOffice(getUrl, putUrl, 'PUT', "dialog.title.office.details");
e.preventDefault();
});
@@ -1245,7 +1255,30 @@ function loadILLoan(baseApiUrl, loanId) {
}
function maintainOffice(getUrl, putOrPostUrl, submitType, dialogTitle) {
var templateSelector = "#officeFormTemplate";
var width = 600;
var height = 400;
var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close");
refreshOfficesView();
}
popupDialogWithFormView(baseApiUrl + getUrl, baseApiUrl + putOrPostUrl, submitType, dialogTitle, templateSelector, width, height, saveSuccessFunction);
}
function maintainOrgCurrencies(getUrl, putOrPostUrl, submitType, dialogTitle) {
var templateSelector = "#configurationFormTemplate";
var width = 900;
var height = 400;
var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close");
}
popupDialogWithFormView(baseApiUrl + getUrl, baseApiUrl + putOrPostUrl, submitType, dialogTitle, templateSelector, width, height, saveSuccessFunction);
}