2020-09-28 01:16:04 +08:00
|
|
|
// Manage the NEW Group button
|
2017-05-19 01:50:56 +08:00
|
|
|
function newGroup() {
|
2020-09-28 01:12:01 +08:00
|
|
|
$j.getJSON(thisUrl + '?request=modal&modal=group')
|
|
|
|
.done(function(data) {
|
2020-10-15 04:58:39 +08:00
|
|
|
insertModalHtml('groupdModal', data.html);
|
2020-09-28 01:12:01 +08:00
|
|
|
$j('#groupModal').modal('show');
|
|
|
|
$j('.chosen').chosen("destroy");
|
|
|
|
$j('.chosen').chosen();
|
|
|
|
// Manage the Save button
|
|
|
|
$j('#grpModalSaveBtn').click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j('#groupForm').submit();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-10-01 02:19:32 +08:00
|
|
|
function setGroup( element ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
form.action.value = 'setgroup';
|
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-04-03 02:13:28 +08:00
|
|
|
function editGroup( element ) {
|
|
|
|
var gid = element.getAttribute('data-group-id');
|
|
|
|
if ( !gid ) {
|
|
|
|
console.log('No group id found in editGroup');
|
|
|
|
} else {
|
2020-09-28 01:12:01 +08:00
|
|
|
$j.getJSON(thisUrl + '?request=modal&modal=group&gid=' + gid)
|
|
|
|
.done(function(data) {
|
2020-10-15 04:58:39 +08:00
|
|
|
insertModalHtml('groupModal', data.html);
|
2020-09-28 01:12:01 +08:00
|
|
|
$j('#groupModal').modal('show');
|
|
|
|
$j('.chosen').chosen("destroy");
|
|
|
|
$j('.chosen').chosen();
|
|
|
|
// Manage the Save button
|
|
|
|
$j('#grpModalSaveBtn').click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j('#groupForm').submit();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
2020-04-03 02:13:28 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function deleteGroup( element ) {
|
|
|
|
var form = element.form;
|
|
|
|
form.view.value = currentView;
|
|
|
|
form.action.value = 'delete';
|
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function configureButtons( element ) {
|
|
|
|
if ( canEditGroups ) {
|
|
|
|
var form = element.form;
|
|
|
|
if ( element.checked ) {
|
|
|
|
form.deleteBtn.disabled = (element.value == 0);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-09-28 01:12:01 +08:00
|
|
|
function configModalBtns() {
|
|
|
|
var form = $j('#groupForm')[0];
|
|
|
|
if ( !form ) {
|
|
|
|
console.log("No groupForm found");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( !canEditGroups ) {
|
|
|
|
console.log("Cannot edit groups");
|
|
|
|
form.elements['action'].disabled = disabled;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var disabled = false;
|
|
|
|
|
|
|
|
if ( form.elements['newGroup[Name]'].value == '' ) {
|
|
|
|
disabled = true;
|
|
|
|
}
|
|
|
|
form.elements['action'].disabled = disabled;
|
|
|
|
}
|