mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
add parameters empty validation with error message && force numeric for page size
align checkbox on the left
This commit is contained in:
parent
c20022562d
commit
8b7ad5b1ff
@ -821,7 +821,7 @@ tbody tr.contact.active, tbody tr.contact:hover {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#addressbooks-ui-div > p > input {
|
||||
#addressbooks-ui-div > p > input:not([type="checkbox"]) {
|
||||
width:200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
@ -101,72 +101,30 @@ OC.Contacts = OC.Contacts || {};
|
||||
});
|
||||
};
|
||||
|
||||
OtherBackendConfig.prototype.addressbookUiOk = function(divDlg) {
|
||||
OtherBackendConfig.prototype.addressbookUiOk = function($divDlg) {
|
||||
var defer = $.Deferred();
|
||||
var addressbook = OC.Contacts.addressBooks;
|
||||
|
||||
$.when(this.storage.addAddressBook($('#addressbooks-ui-backend').val(),
|
||||
{
|
||||
displayname: $('#addressbooks-ui-name').val(),
|
||||
description: $('#addressbooks-ui-description').val(),
|
||||
uri: ($('#addressbooks-ui-uri').val()==='')?$('#addressbooks-ui-name').val():$('#addressbooks-ui-uri').val(),
|
||||
ldapurl: $('#addressbooks-ui-ldapurl').val(),
|
||||
ldapanonymous: $('#addressbooks-ui-ldapanonymous').prop('checked')===true?'true':'false',
|
||||
ldapreadonly: $('#addressbooks-ui-ldapreadonly').prop('checked')===true?'true':'false',
|
||||
ldapuser: $('#addressbooks-ui-ldapuser').val(),
|
||||
ldappass: $('#addressbooks-ui-ldappass').val(),
|
||||
ldappagesize: $('#addressbooks-ui-ldappagesize').val(),
|
||||
ldapbasednsearch: $('#addressbooks-ui-ldapbasednsearch').val(),
|
||||
ldapfilter: $('#addressbooks-ui-ldapfilter').val(),
|
||||
ldapbasednmodify: $('#addressbooks-ui-ldapbasednmodify').val(),
|
||||
ldapvcardconnector: $('#addressbooks-ui-ldapvcardconnector').val(),
|
||||
ldapvcardconnectorvalue: $('#addressbooks-ui-ldapvcardconnector-value').val(),
|
||||
}
|
||||
)).then(function(response) {
|
||||
if(response.error) {
|
||||
error = response.message;
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject(response);
|
||||
} else {
|
||||
console.log('response.data', response.data);
|
||||
var book = addressbook.insertAddressBook(response.data);
|
||||
$(document).trigger('status.addressbook.added');
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:false, addressbook: book});
|
||||
}
|
||||
defer.resolve({error:false, addressbook: book});
|
||||
var error=false;
|
||||
var errorFields = new Array();
|
||||
$('[required]').each(function() {
|
||||
if ($(this).val() == '' && !$(this).attr('disabled')){
|
||||
error = true;
|
||||
errorFields.push($(this).attr('placeholder'));
|
||||
}
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose(divDlg);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
$(this).removeClass('loading');
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log('Request Failed', + err);
|
||||
error = t('contacts', 'Failed adding address book: {error}', {error:err});
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject({error:true, message:error});
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose(divDlg);
|
||||
});
|
||||
};
|
||||
|
||||
OtherBackendConfig.prototype.addressbookUiEditOk = function(divDlg) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
$.when(this.storage.updateAddressBook($('#addressbooks-ui-backend').val(), $('#addressbooks-ui-addressbookid').val(),
|
||||
{properties:
|
||||
if (!error) {
|
||||
$('#addressbooks-ui-errortitle-p').empty();
|
||||
$('#addressbooks-ui-errormessage-p').empty();
|
||||
$.when(this.storage.addAddressBook($('#addressbooks-ui-backend').val(),
|
||||
{
|
||||
displayname: $('#addressbooks-ui-name').val(),
|
||||
description: $('#addressbooks-ui-description').val(),
|
||||
uri: $('#addressbooks-ui-uri').val(),
|
||||
uri: ($('#addressbooks-ui-uri').val()==='')?$('#addressbooks-ui-name').val():$('#addressbooks-ui-uri').val(),
|
||||
ldapurl: $('#addressbooks-ui-ldapurl').val(),
|
||||
ldapanonymous: $('#addressbooks-ui-ldapanonymous').prop('checked')===true?'true':'false',
|
||||
ldapreadonly: $('#addressbooks-ui-ldapreadonly').prop('checked')===true?'true':'false',
|
||||
ldapuser: $('#addressbooks-ui-ldapuser').val(),
|
||||
ldappassmodified: $('#addressbooks-ui-ldappass-modified').val(),
|
||||
ldappass: $('#addressbooks-ui-ldappass').val(),
|
||||
ldappagesize: $('#addressbooks-ui-ldappagesize').val(),
|
||||
ldapbasednsearch: $('#addressbooks-ui-ldapbasednsearch').val(),
|
||||
@ -175,32 +133,102 @@ OC.Contacts = OC.Contacts || {};
|
||||
ldapvcardconnector: $('#addressbooks-ui-ldapvcardconnector').val(),
|
||||
ldapvcardconnectorvalue: $('#addressbooks-ui-ldapvcardconnector-value').val(),
|
||||
}
|
||||
}
|
||||
)).then(function(response) {
|
||||
if(response.error) {
|
||||
error = response.message;
|
||||
)).then(function(response) {
|
||||
if(response.error) {
|
||||
var error = response.message;
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject(response);
|
||||
} else {
|
||||
console.log('response.data', response.data);
|
||||
var book = addressbook.insertAddressBook(response.data);
|
||||
$(document).trigger('status.addressbook.added');
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:false, addressbook: book});
|
||||
}
|
||||
defer.resolve({error:false, addressbook: book});
|
||||
}
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose($divDlg);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
$(this).removeClass('loading');
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log('Request Failed', + err);
|
||||
error = t('contacts', 'Failed adding address book: {error}', {error:err});
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject(response);
|
||||
}
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose(divDlg);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
$(this).removeClass('loading');
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log('Request Failed', + err);
|
||||
error = t('contacts', 'Failed adding address book: {error}', {error:err});
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject({error:true, message:error});
|
||||
});
|
||||
defer.reject({error:true, message:error});
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose($divDlg);
|
||||
});
|
||||
} else {
|
||||
$('#addressbooks-ui-errortitle-p').css('color', 'red').text(t('contacts', 'Error, missing parameters: '));
|
||||
$('#addressbooks-ui-errormessage-p').css('color', 'red').text(errorFields.join(', '));
|
||||
}
|
||||
};
|
||||
|
||||
OtherBackendConfig.prototype.addressbookUiClose = function(divDlg) {
|
||||
divDlg.ocdialog().ocdialog('close');
|
||||
divDlg.ocdialog().ocdialog('destroy').remove();
|
||||
OtherBackendConfig.prototype.addressbookUiEditOk = function($divDlg) {
|
||||
var defer = $.Deferred();
|
||||
|
||||
var error=false;
|
||||
var errorFields = new Array();
|
||||
$('[required]').each(function() {
|
||||
if ($(this).val() == '' && !$(this).attr('disabled')){
|
||||
error = true;
|
||||
errorFields.push($(this).attr('placeholder'));
|
||||
}
|
||||
});
|
||||
if (!error) {
|
||||
$.when(this.storage.updateAddressBook($('#addressbooks-ui-backend').val(), $('#addressbooks-ui-addressbookid').val(),
|
||||
{properties:
|
||||
{
|
||||
displayname: $('#addressbooks-ui-name').val(),
|
||||
description: $('#addressbooks-ui-description').val(),
|
||||
uri: $('#addressbooks-ui-uri').val(),
|
||||
ldapurl: $('#addressbooks-ui-ldapurl').val(),
|
||||
ldapanonymous: $('#addressbooks-ui-ldapanonymous').prop('checked')===true?'true':'false',
|
||||
ldapreadonly: $('#addressbooks-ui-ldapreadonly').prop('checked')===true?'true':'false',
|
||||
ldapuser: $('#addressbooks-ui-ldapuser').val(),
|
||||
ldappassmodified: $('#addressbooks-ui-ldappass-modified').val(),
|
||||
ldappass: $('#addressbooks-ui-ldappass').val(),
|
||||
ldappagesize: $('#addressbooks-ui-ldappagesize').val(),
|
||||
ldapbasednsearch: $('#addressbooks-ui-ldapbasednsearch').val(),
|
||||
ldapfilter: $('#addressbooks-ui-ldapfilter').val(),
|
||||
ldapbasednmodify: $('#addressbooks-ui-ldapbasednmodify').val(),
|
||||
ldapvcardconnector: $('#addressbooks-ui-ldapvcardconnector').val(),
|
||||
ldapvcardconnectorvalue: $('#addressbooks-ui-ldapvcardconnector-value').val(),
|
||||
}
|
||||
}
|
||||
)).then(function(response) {
|
||||
if(response.error) {
|
||||
error = response.message;
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject(response);
|
||||
}
|
||||
OC.Contacts.otherBackendConfig.addressbookUiClose($divDlg);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error) {
|
||||
$(this).removeClass('loading');
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log('Request Failed', + err);
|
||||
error = t('contacts', 'Failed adding address book: {error}', {error:err});
|
||||
if(typeof cb === 'function') {
|
||||
cb({error:true, message:error});
|
||||
}
|
||||
defer.reject({error:true, message:error});
|
||||
});
|
||||
} else {
|
||||
$('#addressbooks-ui-errortitle-p').css('color', 'red').text(t('contacts', 'Error, missing parameters: '));
|
||||
$('#addressbooks-ui-errormessage-p').css('color', 'red').text(errorFields.join(', '));
|
||||
}
|
||||
};
|
||||
|
||||
OtherBackendConfig.prototype.addressbookUiClose = function($divDlg) {
|
||||
$divDlg.ocdialog().ocdialog('close');
|
||||
$divDlg.ocdialog().ocdialog('destroy').remove();
|
||||
};
|
||||
|
||||
OtherBackendConfig.prototype.addressbookUiInit = function() {
|
||||
@ -300,6 +328,31 @@ OC.Contacts = OC.Contacts || {};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#addressbooks-ui-ldappagesize').forceNumericOnly();
|
||||
};
|
||||
|
||||
jQuery.fn.forceNumericOnly = function()
|
||||
{
|
||||
return this.each(function()
|
||||
{
|
||||
$(this).keydown(function(e)
|
||||
{
|
||||
var key = e.charCode || e.keyCode || 0;
|
||||
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
|
||||
// home, end, period, and numpad decimal
|
||||
return (
|
||||
key == 8 ||
|
||||
key == 9 ||
|
||||
key == 13 ||
|
||||
key == 46 ||
|
||||
key == 110 ||
|
||||
key == 190 ||
|
||||
(key >= 35 && key <= 40) ||
|
||||
(key >= 48 && key <= 57) ||
|
||||
(key >= 96 && key <= 105));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
})(window, jQuery, OC);
|
||||
|
@ -596,7 +596,7 @@ use OCA\Contacts\ImportManager;
|
||||
<?php p($l->t('Base DN for modification')); ?>:
|
||||
</label>
|
||||
<input type="text" class="nonempty value" id="addressbooks-ui-ldapbasednmodify" value=""
|
||||
placeholder="<?php p($l->t('Base DN')); ?>" required />
|
||||
placeholder="<?php p($l->t('Base DN modification')); ?>" required />
|
||||
</p>
|
||||
<p id="addressbooks-ui-ldapvcardconnector-p">
|
||||
<label for="addressbooks-ui-ldapvcardconnector">
|
||||
@ -618,5 +618,9 @@ use OCA\Contacts\ImportManager;
|
||||
<select id="addressbooks-ui-ldapvcardconnector-copyfrom">
|
||||
</select>
|
||||
</p>
|
||||
<p id="addressbooks-ui-errortitle-p">
|
||||
</p>
|
||||
<p id="addressbooks-ui-errormessage-p">
|
||||
</p>
|
||||
</div>
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user