wip javascript

This commit is contained in:
John Woodlock
2012-07-05 16:44:28 +10:00
parent 63c91e38a9
commit 06a1254abd
2 changed files with 123 additions and 52 deletions
+23 -25
View File
@@ -1212,9 +1212,9 @@
<table id='entitytable' width='100%'> <table id='entitytable' width='100%'>
<thead> <thead>
<tr> <tr>
<th><spring:message code="table.heading.permission.type"/></th> <th>{{=$ctx.doI18N("table.heading.permission.type")}}</th>
<th><spring:message code="table.heading.permission.permission"/></th> <th>{{=$ctx.doI18N("table.heading.permission.permission")}}</th>
<th><spring:message code="table.heading.permission.description"/></th> <th>{{=$ctx.doI18N("table.heading.permission.description")}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -1252,8 +1252,8 @@
<table id='entitytable' width='100%'> <table id='entitytable' width='100%'>
<thead> <thead>
<tr> <tr>
<th><spring:message code="table.heading.rolename"/></th> <th>{{=$ctx.doI18N("table.heading.rolename")}}</th>
<th><spring:message code="table.heading.description"/></th> <th>{{=$ctx.doI18N("table.heading.description")}}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
</thead> </thead>
@@ -1263,10 +1263,8 @@
<td>{{=name}}</td> <td>{{=name}}</td>
<td>{{=description}}</td> <td>{{=description}}</td>
<td> <td>
<a id='edit{{=id}}' class='edit' href='#' style='margin-right: 5px;'><spring:message code="link.action.product.viewedit"/></a> <a id='edit{{=id}}' class='edit' href='#' style='margin-right: 5px;'>{{=$ctx.doI18N("link.action.product.viewedit")}}</a>
<!-- <a id='delete{{=id}}' class='delete' href='#' style='margin-right: 5px;'>{{=$ctx.doI18N("link.action.product.delete")}}</a>
<a id='delete{{=id}}' class='delete' href='#' style='margin-right: 5px;'><spring:message code="link.action.product.delete"/></a>
-->
</td> </td>
</tr> </tr>
{{/each}} {{/each}}
@@ -1308,21 +1306,21 @@
<fieldset> <fieldset>
<legend>{{=$ctx.doI18N("form.legend.user.details")}}</legend> <legend>{{=$ctx.doI18N("form.legend.user.details")}}</legend>
<label for="username"><spring:message code="form.label.user.username"/></label> <label for="username">{{=$ctx.doI18N("form.label.user.username")}}</label>
<input id="username" name="username" title="" type="text" value="{{=username}}" size="75"/> <input id="username" name="username" title="" type="text" value="{{=username}}" size="75"/>
<label for="firstname"><spring:message code="form.label.user.firstname"/></label> <label for="firstname">{{=$ctx.doI18N("form.label.user.firstname")}}</label>
<input id="firstname" name="firstname" title="" type="text" value="{{=firstname}}" size="75"/> <input id="firstname" name="firstname" title="" type="text" value="{{=firstname}}" size="75"/>
<label for="lastname"><spring:message code="form.label.user.lastname"/></label> <label for="lastname">{{=$ctx.doI18N("form.label.user.lastname")}}</label>
<input id="lastname" name="lastname" title="" type="text" value="{{=lastname}}" size="75"/> <input id="lastname" name="lastname" title="" type="text" value="{{=lastname}}" size="75"/>
<label for="email"><spring:message code="form.label.user.email"/></label> <label for="email">{{=$ctx.doI18N("form.label.user.email")}}</label>
<input id="email" name="email" title="" type="text" value="{{=email}}" size="75"/> <input id="email" name="email" title="" type="text" value="{{=email}}" size="75"/>
<label for="officeId"><spring:message code="form.label.user.office"/></label> <label for="officeId">{{=$ctx.doI18N("form.label.user.office")}}</label>
<select id="officeId" name="officeId" title=""> <select id="officeId" name="officeId" title="">
<option value="-1"><spring:message code="option.office.first.choice"/></option> <option value="-1">{{=$ctx.doI18N("option.office.first.choice")}}</option>
{{#each allowedOffices}} {{#each allowedOffices}}
{{#if $ctx.number($parent.parent.data.officeId)===$ctx.number(id)}} {{#if $ctx.number($parent.parent.data.officeId)===$ctx.number(id)}}
<option value="{{=$ctx.number(id)}}" selected="selected">{{=name}}</option> <option value="{{=$ctx.number(id)}}" selected="selected">{{=name}}</option>
@@ -1334,23 +1332,23 @@
<br/> <br/>
<div class="multiselectwidget"> <div class="multiselectwidget">
<label for="notSelectedRoles"><spring:message code="form.label.user.available.roles"/></label> <label for="notSelectedRoles">{{=$ctx.doI18N("form.label.user.available.roles")}}</label>
<select id="notSelectedRoles" name="notSelectedRoles" title="Available application roles." class="multiselectwidget multiNotSelectedItems" multiple="multiple" style="width:450px;height:125px;"> <select id="notSelectedRoles" name="notSelectedRoles" title="Available application roles." class="multiselectwidget multiNotSelectedItems" multiple="multiple" style="width:450px;height:125px;">
{{#each availableRoles}} {{#each availableRoles}}
<option value="{{=id}}">{{=name}}</option> <option value="{{=id}}">{{=name}}</option>
{{/each}} {{/each}}
</select> </select>
<a href="#" id="add" class="multiselectwidget multiadd"><spring:message code="widget.multiselect.button.add"/> &gt;&gt;</a> <a href="#" id="addroles" class="multiselectwidget multiadd">{{=$ctx.doI18N("widget.multiselect.button.add")}} &gt;&gt;</a>
</div> </div>
<div class="multiselectwidget"> <div class="multiselectwidget">
<label for="roles"><spring:message code="form.label.user.selected.roles"/></label> <label for="roles">{{=$ctx.doI18N("form.label.user.selected.roles")}}</label>
<select id="roles" name="roles" title="User selected roles." class="multiselectwidget multiSelectedItems" multiple="multiple" style="width:450px;height:125px;"> <select id="roles" name="roles" title="User selected roles." class="multiselectwidget multiSelectedItems" multiple="multiple" style="width:450px;height:125px;">
{{#each selectedRoles}} {{#each selectedRoles}}
<option value="{{=id}}" selected="selected">{{=name}}</option> <option value="{{=id}}" selected="selected">{{=name}}</option>
{{/each}} {{/each}}
</select> </select>
<a href="#" id="remove" class="multiselectwidget multiremove">&lt;&lt; <spring:message code="widget.multiselect.button.remove"/></a> <a href="#" id="removeroles" class="multiselectwidget multiremove">&lt;&lt; {{=$ctx.doI18N("widget.multiselect.button.remove")}}</a>
</div> </div>
</fieldset> </fieldset>
</form> </form>
@@ -1360,23 +1358,23 @@
<form id="entityform"> <form id="entityform">
<div id="formerrors"></div> <div id="formerrors"></div>
<fieldset> <fieldset>
<legend><spring:message code="form.legend.role.details"/></legend> <legend>{{=$ctx.doI18N("form.legend.role.details")}}</legend>
<label for="name"><spring:message code="form.label.role.name"/></label> <label for="name">{{=$ctx.doI18N("form.label.role.name")}}</label>
<input id="name" name="name" title="" type="text" value="{{=name}}" size="75"/> <input id="name" name="name" title="" type="text" value="{{=name}}" size="75"/>
<label for="description"><spring:message code="form.label.role.description"/></label> <label for="description">{{=$ctx.doI18N("form.label.role.description")}}</label>
<textarea cols="73" rows="3" id="description" name="description" title="">{{=description}}</textarea> <textarea cols="73" rows="3" id="description" name="description" title="">{{=description}}</textarea>
<br/> <br/>
<div class="multiselectwidget"> <div class="multiselectwidget">
<label for="notSelectedPermissions"><spring:message code="form.label.role.available.permissions"/></label> <label for="notSelectedPermissions">{{=$ctx.doI18N("form.label.role.available.permissions")}}</label>
<select id="notSelectedPermissions" name="notSelectedPermissions" title="" class="multiselectwidget multiNotSelectedItems" multiple="multiple" style="width:450px;height:125px;"> <select id="notSelectedPermissions" name="notSelectedPermissions" title="" class="multiselectwidget multiNotSelectedItems" multiple="multiple" style="width:450px;height:125px;">
{{#each availablePermissions}} {{#each availablePermissions}}
<option value="{{=id}}" title="{{=description}}">{{=name}}</option> <option value="{{=id}}" title="{{=description}}">{{=name}}</option>
{{/each}} {{/each}}
</select> </select>
<a href="#" id="add" class="multiselectwidget multiadd"><spring:message code="widget.multiselect.button.add"/> &gt;&gt;</a> <a href="#" id="addpermissions" class="multiselectwidget multiadd">{{=$ctx.doI18N("widget.multiselect.button.add")}} &gt;&gt;</a>
</div> </div>
<div class="multiselectwidget"> <div class="multiselectwidget">
@@ -1386,7 +1384,7 @@
<option value="{{=id}}" title="{{=description}}">{{=name}}</option> <option value="{{=id}}" title="{{=description}}">{{=name}}</option>
{{/each}} {{/each}}
</select> </select>
<a href="#" id="remove" class="multiselectwidget multiremove">&lt;&lt; <spring:message code="widget.multiselect.button.remove"/></a> <a href="#" id="removepermissions" class="multiselectwidget multiremove">&lt;&lt; {{=$ctx.doI18N("widget.multiselect.button.remove")}}</a>
</div> </div>
</fieldset> </fieldset>
</form> </form>
+98 -25
View File
@@ -131,22 +131,21 @@ function setOrgAdminContent(divName) {
function setUserAdminContent(divName) { function setUserAdminContent(divName) {
var addLoanProductUrl = "maintainLoanProduct('loanproducts/template', 'loanproducts', 'POST', 'dialog.title.add.loan.product');return false;"; var addUserUrl = "maintainUser('users/template', 'users', 'POST', 'dialog.title.add.user');return false;";
var addOfficeUrl = "maintainOffice('offices/template', 'offices', 'POST', 'dialog.title.add.office');return false;"; var addRoleUrl = "maintainRole('roles/template', 'roles', 'POST', 'dialog.title.add.role');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 id="inputarea"></div><div id="schedulearea"></div>'
var htmlVar = '<div>'; var htmlVar = '<div>';
htmlVar += '<span style="float: left">'; htmlVar += '<span style="float: left">';
htmlVar += ' <a href="unknown.html" onclick="refreshUsersView();return false;" id="listusers">' + doI18N("administration.link.view.users") + '</a>'; htmlVar += ' <a href="unknown.html" onclick="refreshUsersView();return false;" id="listusers">' + doI18N("administration.link.view.users") + '</a>';
htmlVar += ' | '; htmlVar += ' | ';
htmlVar += ' <a href="unknown.html" onclick="' + addLoanProductUrl + '" id="adduser">' + doI18N("administration.link.add.user") + '</a>'; htmlVar += ' <a href="unknown.html" onclick="' + addUserUrl + '" id="adduser">' + doI18N("administration.link.add.user") + '</a>';
htmlVar += ' | '; htmlVar += ' | ';
htmlVar += ' <a href="unknown.html" onclick="refreshOfficesView();return false;" id="listroles">' + doI18N("administration.link.view.roles") + '</a>'; htmlVar += ' <a href="unknown.html" onclick="refreshRolesView();return false;" id="listroles">' + doI18N("administration.link.view.roles") + '</a>';
htmlVar += ' | '; htmlVar += ' | ';
htmlVar += ' <a href="unknown.html" onclick="' + addOfficeUrl + '" id="addrole">' + doI18N("administration.link.add.role") + '</a>'; htmlVar += ' <a href="unknown.html" onclick="' + addRoleUrl + '" id="addrole">' + doI18N("administration.link.add.role") + '</a>';
htmlVar += ' | '; htmlVar += ' | ';
htmlVar += ' <a href="unknown.html" onclick="' + orgCurrenciesUrl + '" id="listpermissions">' + doI18N("administration.link.view.permissions") + '</a>'; htmlVar += ' <a href="unknown.html" onclick="refreshPermissionsView();return false;" id="listpermissions">' + doI18N("administration.link.view.permissions") + '</a>';
htmlVar += '</span>'; htmlVar += '</span>';
htmlVar += '</div>'; htmlVar += '</div>';
htmlVar += '<br><br>'; htmlVar += '<br><br>';
@@ -502,26 +501,21 @@ function jsViewsRegisterHelpers() {
$(this).remove(); $(this).remove();
}, },
open: function (event, ui) { open: function (event, ui) {
/*
if (roles) { $('#addpermissions').click(function() {
$('#add').click(function() { return !$('#notSelectedPermissions option:selected').remove().appendTo('#permissions');
return !$('#notSelectedPermissions option:selected').remove().appendTo('#permissions'); });
}); $('#removepermissions').click(function() {
return !$('#permissions option:selected').remove().appendTo('#notSelectedPermissions');
});
$('#remove').click(function() { $('#addroles').click(function() {
return !$('#permissions option:selected').remove().appendTo('#notSelectedPermissions'); return !$('#notSelectedRoles option:selected').remove().appendTo('#roles');
}); });
} else { $('#removeroles').click(function() {
$('#add').click(function() { return !$('#roles option:selected').remove().appendTo('#notSelectedRoles');
return !$('#notSelectedRoles option:selected').remove().appendTo('#roles'); });
});
$('#remove').click(function() {
return !$('#roles option:selected').remove().appendTo('#notSelectedRoles');
});
}
*/
$('#add').click(function() { $('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems'); return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
}); });
@@ -1245,7 +1239,6 @@ function loadILLoan(loanId) {
executeAjaxRequest('users', 'GET', "", successFunction, formErrorFunction); executeAjaxRequest('users', 'GET', "", successFunction, formErrorFunction);
} }
function maintainUser(getUrl, putOrPostUrl, submitType, dialogTitle) { function maintainUser(getUrl, putOrPostUrl, submitType, dialogTitle) {
var templateSelector = "#userFormTemplate"; var templateSelector = "#userFormTemplate";
@@ -1259,7 +1252,87 @@ function loadILLoan(loanId) {
popupDialogWithFormView(getUrl, putOrPostUrl, submitType, dialogTitle, templateSelector, width, height, saveSuccessFunction); popupDialogWithFormView(getUrl, putOrPostUrl, submitType, dialogTitle, templateSelector, width, height, saveSuccessFunction);
} }
function refreshRolesView() {
var successFunction = function(data, textStatus, jqXHR) {
var rolesObject = new Object();
rolesObject.roles = data;
var listHtml = $("#roleListTemplate").render(rolesObject);
$("#contentplaceholder").html(listHtml);
$("a.edit").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("edit", "");
var getUrl = 'roles/' + entityId + '?template=true';
var putUrl = 'roles/' + entityId;
maintainRole(getUrl, putUrl, 'PUT', "dialog.title.edit.details");
e.preventDefault();
});
$("a.delete").click( function(e) {
//var linkId = this.id;
//var entityId = linkId.replace("delete", "");
showNotAvailableDialog('dialog.title.functionality.not.available');
e.preventDefault();
});
var oTable = $("#entitytable").dataTable( {
"bSort": true,
"bInfo": true,
"bJQueryUI": true,
"bRetrieve": false,
"bScrollCollapse": false,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bAutoWidth": false,
} );
};
executeAjaxRequest('roles', 'GET', "", successFunction, formErrorFunction);
}
function maintainRole(getUrl, putOrPostUrl, submitType, dialogTitle) {
var templateSelector = "#roleFormTemplate";
var width = 1000;
var height = 550;
var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close");
refreshRolesView();
}
popupDialogWithFormView(getUrl, putOrPostUrl, submitType, dialogTitle, templateSelector, width, height, saveSuccessFunction);
}
function refreshPermissionsView() {
var templateSelector = "#permissionListTemplate";
var displayAreaDivSelector = "#contentplaceholder";
var successFunction = function(data, textStatus, jqXHR) {
var permissionsObject = new Object();
permissionsObject.permissions = data;
var listHtml = $(templateSelector).render(permissionsObject);
$(displayAreaDivSelector).html(listHtml);
var oTable = $("#entitytable").dataTable( {
"bSort": true,
"bInfo": true,
"bJQueryUI": true,
"bRetrieve": false,
"bScrollCollapse": false,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bAutoWidth": false,
} );
};
executeAjaxRequest('permissions', 'GET', "", successFunction, formErrorFunction);
}