summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/ui/details.js42
-rw-r--r--install/ui/entity.js8
-rw-r--r--install/ui/ipa.js36
-rw-r--r--install/ui/navigation.js9
-rw-r--r--install/ui/test/data/ipa_init.json3
-rw-r--r--install/ui/webui.js16
-rw-r--r--install/ui/widget.js36
-rw-r--r--ipalib/plugins/internal.py3
8 files changed, 130 insertions, 23 deletions
diff --git a/install/ui/details.js b/install/ui/details.js
index 84a5c4098..c9e78bdef 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -49,6 +49,16 @@ IPA.details_field = function (spec) {
that.record = record;
that.values = record[that.name];
that.reset();
+
+ var param_info = IPA.get_param_info(that.entity_name, that.name);
+ if (param_info) {
+ if (param_info['primary_key']) {
+ that.read_only = true;
+ }
+ if ('no_update' in param_info['flags']) {
+ that.read_only = true;
+ }
+ }
}
that.update = function() {
@@ -129,7 +139,10 @@ IPA.details_field = function (spec) {
var label = $('<label/>', { html:value.toString() });
- if (!IPA.is_field_writable(rights)) return label;
+ if (!IPA.is_field_writable(rights)) {
+ that.read_only = true;
+ return label;
+ }
var param_info = IPA.get_param_info(that.entity_name, that.name);
if (param_info) {
@@ -191,6 +204,7 @@ IPA.details_field = function (spec) {
}).appendTo(span) ;
if (!IPA.is_field_writable(rights)) {
+ that.read_only = true;
input.attr('disabled', 'disabled');
}
@@ -383,6 +397,16 @@ IPA.details_section = function (spec){
}
};
+ that.is_dirty = function(){
+ for (var i=0; i<that.fields.length; i++) {
+ var field = that.fields[i];
+ if (field.is_dirty()){
+ return true;
+ }
+ }
+ return false;
+ }
+
// methods that should be invoked by subclasses
that.section_init = that.init;
that.section_create = that.create;
@@ -653,10 +677,24 @@ IPA.details_facet = function (spec) {
}
}
- function is_dirty() {
+ function new_key(){
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
return pkey != that.pkey;
}
+ that.new_key = new_key;
+
+
+ function is_dirty() {
+
+ var i;
+ for ( i =0; i < that.sections.length; i +=1 ){
+ if (that.sections[i].is_dirty()){
+ return true;
+ }
+ }
+
+ return false;
+ }
function load(record) {
that.record = record;
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 8d39b8e79..990d2eb74 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -63,6 +63,10 @@ IPA.facet = function (spec) {
function load() {
}
+ that.is_dirty = function (){
+ return false;
+ }
+
that.get_client_area = function() {
return $('.client', that.container);
};
@@ -371,6 +375,7 @@ IPA.entity_setup = function (container) {
var entity = this;
+ IPA.current_entity = this;
var facet_name = IPA.current_facet(entity);
@@ -379,8 +384,7 @@ IPA.entity_setup = function (container) {
if (IPA.entity_name == entity.name) {
if (entity.facet_name == facet_name) {
- if (!facet.is_dirty()) return;
-
+ if (facet.new_key && (!facet.new_key())) return;
} else {
entity.facet_name = facet_name;
}
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 406dce6d4..128413b1e 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -131,7 +131,38 @@ var IPA = ( function () {
}
};
+
+ that.test_dirty = function(){
+ if (IPA.current_entity){
+ var facet_name = IPA.current_facet(IPA.current_entity);
+ var facet = IPA.current_entity.facets_by_name[facet_name];
+ if (facet.is_dirty()){
+ var message_box = $("<div/>",{
+ html: IPA.messages.dirty
+ }).
+ appendTo($("#navigation"));
+ message_box.dialog({
+ title: 'Dirty',
+ modal:true,
+ width: '20em',
+ buttons: {
+ Ok: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+
that.show_page = function (entity_name, facet_name) {
+ if (!IPA.test_dirty()){
+ return false;
+ }
var state = {};
state[entity_name + '-facet'] = facet_name;
@@ -139,6 +170,11 @@ var IPA = ( function () {
};
that.switch_and_show_page = function (this_entity, facet_name, pkey) {
+
+ if (!IPA.test_dirty()){
+ return false;
+ }
+
if (!pkey){
that.show_page(this_entity, facet_name);
return;
diff --git a/install/ui/navigation.js b/install/ui/navigation.js
index 0b8fe528e..4a3fe6916 100644
--- a/install/ui/navigation.js
+++ b/install/ui/navigation.js
@@ -23,9 +23,15 @@
var nav_tabs_lists;
var nav_container;
+
+
function nav_push_state(params)
{
+ if (!IPA.test_dirty()){
+ return false;
+ }
$.bbq.pushState(params);
+ return true;
}
function nav_get_state(key)
@@ -58,8 +64,7 @@ function nav_create(nls, container, tabclass)
var id = parent.attr('id');
var state = {};
state[id] = ui.index;
- nav_push_state(state);
- return true;
+ return nav_push_state(state);
}
});
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index a4b9a0f79..40be12288 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -7398,6 +7398,7 @@
"misc": "Misc. Information",
"to_top": "Back to Top"
},
+ "dirty": "This page has unsaved changes. Please save or revert.",
"facets": {
"details": "Settings",
"search": "Search"
@@ -7447,7 +7448,7 @@
"20110126193538Z"
],
"krblastsuccessfulauth": [
- "20110126194824Z"
+ "20110127024034Z"
],
"krbpasswordexpiration": [
"20110426193538Z"
diff --git a/install/ui/webui.js b/install/ui/webui.js
index 9459c9d1c..a762654b0 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -116,6 +116,12 @@ IPA.tab_state = function(entity_name){
/* main (document onready event handler) */
$(function() {
+ /* main loop (hashchange event handler) */
+ function window_hashchange(evt){
+ nav_update_tabs();
+ }
+
+
function should_show_all_ui(){
var whoami = IPA.whoami;
@@ -167,13 +173,3 @@ $(function() {
IPA.init(null, null, init_on_win, init_on_error);
});
-
-/* main loop (hashchange event handler) */
-function window_hashchange(evt){
- nav_update_tabs();
-}
-
-/* builder function for unimplemented tab content */
-function unimplemented_tab(jobj){
- jobj.text('Not implemented yet!');
-}
diff --git a/install/ui/widget.js b/install/ui/widget.js
index cea86fad0..9f7c8cae8 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -126,14 +126,40 @@ IPA.widget = function(spec) {
}
that.is_dirty = function() {
-
+ if (that.read_only) {
+ return false;
+ }
var values = that.save();
- if (!values && !that.values) return false;
- if (!values || !that.values) return true;
- if (values.length != that.values.length) return true;
+ if (!that.values){
+ if (!values) {
+ return false;
+ }
+ if ( values === "" ){
+ return false;
+ }
+ if ((values instanceof Array) &&
+ (values.length ===1) &&
+ (values[0] === "")){
+ return false;
+ }
+
+ if ((values instanceof Array) &&
+ (values.length === 0)){
+ return false;
+ }
+
+ if (values) {
+ return true;
+ }
+ }
+ if (values.length != that.values.length) {
+ return true;
+ }
for (var i=0; i<values.length; i++) {
- if (values[i] != that.values[i]) return true;
+ if (values[i] != that.values[i]) {
+ return true;
+ }
}
return false;
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index ab53a0538..66ad45f2a 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -122,7 +122,8 @@ class i18n_messages(Command):
"If this is your first time running the IPA Web UI"+
"<a href='/ipa/errors/ssbrowser.html'> "+
"Follow these directions</a> to configure your browser.")
- }
+ },
+ "dirty":_("This page has unsaved changes. Please save or revert."),
}
has_output = (
Output('messages', dict, doc=_('Dict of I18N messages')),