[open-ils-commits] r17093 - in trunk/Open-ILS/xul/staff_client/server: cat skin (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 5 03:50:42 EDT 2010
Author: phasefx
Date: 2010-08-05 03:50:37 -0400 (Thu, 05 Aug 2010)
New Revision: 17093
Modified:
trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js
trunk/Open-ILS/xul/staff_client/server/skin/cat.css
Log:
disable Create/Modify button in item attribute editor if Required fields are Unset
Modified: trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js 2010-08-05 07:50:35 UTC (rev 17092)
+++ trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js 2010-08-05 07:50:37 UTC (rev 17093)
@@ -160,6 +160,7 @@
g.summarize( g.copies );
g.render();
+ g.check_for_unmet_required_fields();
} catch(E) {
var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/copy_editor.js', E]);
@@ -219,6 +220,7 @@
}
g.summarize( g.copies );
g.render();
+ g.check_for_unmet_required_fields();
}
} catch(E) {
g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.apply_templates.error'), E);
@@ -385,6 +387,7 @@
g.copies = JSON2js( g.original_copies );
g.summarize( g.copies );
g.render();
+ g.check_for_unmet_required_fields();
}
/******************************************************************************************************/
@@ -392,10 +395,16 @@
g.apply = function(field,value) {
g.error.sdump('D_TRACE','applying field = <' + field + '> value = <' + value + '>\n');
- if (value == '<HACK:KLUDGE:NULL>') value = null;
+ if (value == '<HACK:KLUDGE:NULL>') {
+ value = null;
+ }
if (field == 'alert_message') { value = value.replace(/^\W+$/g,''); }
if (field == 'price' || field == 'deposit_amount') {
- if (value == '') { value = null; } else { JSAN.use('util.money'); value = util.money.sanitize( value ); }
+ if (value == '') {
+ value = null;
+ } else {
+ JSAN.use('util.money'); value = util.money.sanitize( value );
+ }
}
for (var i = 0; i < g.copies.length; i++) {
var copy = g.copies[i];
@@ -424,12 +433,14 @@
return (obj.stat_cat() != sc_id);
}
);
- if (entry_id > -1) temp.push(
- util.functional.find_id_object_in_list(
- g.data.hash.asc[sc_id].entries(),
- entry_id
- )
- );
+ if (entry_id > -1) {
+ temp.push(
+ util.functional.find_id_object_in_list(
+ g.data.hash.asc[sc_id].entries(),
+ entry_id
+ )
+ );
+ }
copy.stat_cat_entries( temp );
} catch(E) {
@@ -663,11 +674,17 @@
/******************************************************************************************************/
-/* This keeps track of what fields have been edited for styling purposes */
+/* This keeps track of which fields have been edited for styling purposes */
g.changed = {};
/******************************************************************************************************/
+/* This keeps track of which fields are required, and which fields have been populated */
+
+g.required = {};
+g.populated = {};
+
+/******************************************************************************************************/
/* These need data from the middle layer to render */
function init_panes0() {
@@ -963,6 +980,7 @@
var render = g.field_names[i][1].render;
var attr = g.field_names[i][1].attr;
g.summary[ field_name ] = {};
+ g.populated[ field_name ] = 1; // delete later if we encounter a copy with the field unset
/******************************************************************************************************/
/* Loop through the copies */
@@ -971,7 +989,7 @@
var fm = copies[j];
var cmd = render || ('fm.' + field_name + '();');
- var value = '???';
+ var value = $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null");
/**********************************************************************************************/
/* Try to retrieve the value for this field for this copy */
@@ -984,6 +1002,9 @@
if (typeof value == 'object' && value != null) {
alert('FIXME: field_name = <' + field_name + '> value = <' + js2JSON(value) + '>\n');
}
+ if (value == $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null")) {
+ delete g.populated[field_name];
+ }
/**********************************************************************************************/
/* Tally the count */
@@ -1060,6 +1081,7 @@
caption.setAttribute('id','caption_'+fn); // used for focus/keyboard navigation
vbox = document.createElement('vbox'); groupbox.appendChild(vbox); // main display widget goes here
if (typeof g.changed[fn] != 'undefined') { addCSSClass(vbox,'copy_editor_field_changed'); }
+ if (typeof g.required[fn] != 'undefined') { addCSSClass(vbox,'copy_editor_field_required'); }
grid = util.widgets.make_grid( [ { 'flex' : 1 }, {}, {} ] ); vbox.appendChild(grid);
grid.setAttribute('flex','1');
rows = grid.lastChild;
@@ -1182,6 +1204,7 @@
function() {
g.summarize( g.copies );
g.render();
+ g.check_for_unmet_required_fields();
document.getElementById(caption.id).focus();
}, 0
);
@@ -1202,7 +1225,16 @@
apply.addEventListener('command',function() { c(x.value); },false);
var cancel = document.createElement('button');
cancel.setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.cancel.label'));
- cancel.addEventListener('command',function() { setTimeout( function() { g.summarize( g.copies ); g.render(); document.getElementById(caption.id).focus(); }, 0); }, false);
+ cancel.addEventListener('command',function() {
+ setTimeout( function() {
+ g.summarize( g.copies );
+ g.render();
+ g.check_for_unmet_required_fields();
+ document.getElementById(caption.id).focus();
+ }, 0
+ );
+ }, false
+ );
hbox2.appendChild(cancel);
setTimeout( function() { x.focus(); }, 0 );
}
@@ -1327,6 +1359,10 @@
var label_name = g.data.hash.aou[ sc.owner() ].shortname() + " : " + sc.name();
+ if (get_bool( sc.required() )) {
+ g.required[ label_name ] = 1;
+ }
+
var temp_array = [
label_name,
{
@@ -1352,7 +1388,7 @@
g.populate_stat_cats = function() {
try {
g.data.stash_retrieve();
- g.stat_cat_seen = {};
+ g.stat_cat_seen = {}; // used for determining whether a stat cat is displayed (and is eligible to be manipulated via a template)
function get(lib_id,only_these) {
g.data.stash_retrieve();
@@ -1448,4 +1484,18 @@
}
}
+g.check_for_unmet_required_fields = function() {
+ var abort = [];
+ for (var fn in g.required) {
+ if (typeof g.populated[fn] == 'undefined') {
+ abort.push(fn);
+ }
+ }
+ if (abort.length > 0) {
+ $('save').setAttribute('disabled','true');
+ } else {
+ $('save').setAttribute('disabled','false');
+ }
+}
+
Modified: trunk/Open-ILS/xul/staff_client/server/skin/cat.css
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/skin/cat.css 2010-08-05 07:50:35 UTC (rev 17092)
+++ trunk/Open-ILS/xul/staff_client/server/skin/cat.css 2010-08-05 07:50:37 UTC (rev 17093)
@@ -6,4 +6,5 @@
.has_copies { color: black; background-color: lightgreen; font-weight: bold; }
.copy_editor_field_changed { background: lightgreen; }
+.copy_editor_field_required { border: solid thin red; }
More information about the open-ils-commits
mailing list