summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2017-01-16 13:59:16 +0100
committerTomas Krizek <tkrizek@redhat.com>2017-03-08 10:14:21 +0100
commit27027bbc9cf7faa29c3c94686635559cbcbde98a (patch)
tree18e497a4a7434e13dc809a3aefdfb90cd02539e2
parentadf8aabf10a57383aa6216625921503b83575757 (diff)
downloadfreeipa-27027bbc9cf7faa29c3c94686635559cbcbde98a.tar.gz
freeipa-27027bbc9cf7faa29c3c94686635559cbcbde98a.tar.xz
freeipa-27027bbc9cf7faa29c3c94686635559cbcbde98a.zip
WebUI: Add possibility to set field always writable
If field will have set attribute 'always_writable' to true, then 'no_update' flag will be ingored. Used in command user-{add,remove}-certmap which needs to be writable in WebUI and also needs to be omitted from user-mod command. Part of: https://fedorahosted.org/freeipa/ticket/6601 Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r--install/ui/src/freeipa/field.js43
-rw-r--r--install/ui/src/freeipa/widget.js35
2 files changed, 52 insertions, 26 deletions
diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js
index d70a77890..9f287dd33 100644
--- a/install/ui/src/freeipa/field.js
+++ b/install/ui/src/freeipa/field.js
@@ -484,7 +484,16 @@ field.field = IPA.field = function(spec) {
writable = false;
}
- if (that.metadata.flags && array.indexOf(that.metadata.flags, 'no_update') > -1) {
+ // In case that field has set always_writable attribute, then
+ // 'no_update' flag is ignored in WebUI. It is done because of
+ // commands like user-{add,remove}-certmap. They operate with user's
+ // attribute, which cannot be changed using user-mod, but only
+ // using command user-{add,remove}-certmap. Therefore it has set
+ // 'no_update' flag, but we need to show 'Add', 'Remove' buttons in
+ // WebUI.
+ if (that.metadata.flags &&
+ array.indexOf(that.metadata.flags, 'no_update') > -1 &&
+ !that.always_writable) {
writable = false;
}
}
@@ -1259,6 +1268,37 @@ field.certs_field = IPA.certs_field = function(spec) {
return that;
};
+
+/**
+ * Used along with custom_command_multivalued widget
+ *
+ * - by default has `w_if_no_aci` to workaround missing object class
+ * - by default has always_writable=true to workaround aci rights
+ *
+ * @class
+ * @alternateClassName IPA.custom_command_multivalued_field
+ * @extends IPA.field
+ */
+field.certmap_command_multivalued_field = function(spec) {
+
+ spec = spec || {};
+ spec.flags = spec.flags || ['w_if_no_aci'];
+
+ var that = IPA.field(spec);
+
+ /**
+ * Set field always writable in case that it is set to true
+ * @param Boolean always_writable
+ */
+ that.always_writable = spec.always_writable === undefined ? true :
+ spec.always_writable;
+
+ return that;
+};
+
+
+IPA.custom_command_multivalued_field = field.custom_command_multivalued_field;
+
/**
* SSH Keys Adapter
* @class
@@ -1652,6 +1692,7 @@ field.register = function() {
f.register('checkbox', field.checkbox_field);
f.register('checkboxes', field.field);
f.register('combobox', field.field);
+ f.register('certmap_multivalued', field.certmap_command_multivalued_field);
f.register('datetime', field.datetime_field);
f.register('enable', field.enable_field);
f.register('entity_select', field.field);
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 15f012673..b7028a9bf 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1534,12 +1534,8 @@ IPA.custom_command_multivalued_widget = function(spec) {
* Called on error of add command. Override point.
*/
that.on_error_add = function(xhr, text_status, error_thrown) {
- that.adder_dialog.focus_first_element();
-
- if (error_thrown.message) {
- var msg = error_thrown.message;
- IPA.notify(msg, 'error');
- }
+ that.adder_dialog.show();
+ exp.focus_invalid(that.adder_dialog);
};
/**
@@ -1599,27 +1595,16 @@ IPA.custom_command_multivalued_widget = function(spec) {
name: 'custom-add-dialog'
};
- that.adder_dialog = IPA.dialog(spec);
- that.adder_dialog.create_button({
- name: 'add',
- label: '@i18n:buttons.add',
- click: function() {
- if (!that.adder_dialog.validate()) {
- exp.focus_invalid(that.adder_dialog);
- }
- else {
- that.add(that.adder_dialog);
- }
+ spec.on_ok = function() {
+ if (!that.adder_dialog.validate()) {
+ exp.focus_invalid(that.adder_dialog);
}
- });
-
- that.adder_dialog.create_button({
- name: 'cancel',
- label: '@i18n:buttons.cancel',
- click: function() {
- that.adder_dialog.close();
+ else {
+ that.add(that.adder_dialog);
}
- });
+ };
+
+ that.adder_dialog = IPA.custom_command_multivalued_dialog(spec);
};
/* on button 'Add' on adder dialog click */