Commit f9ad9ff43e3bd577a1aa49f1bd2e501933d179f0

Authored by Megan Watson
1 parent a56cfc9c

KTC-524

"When Editing Fieldset Rules for Conditional Fieldset, clicking edit field displays incorrect control/dependent group, inconsistent with configured Field Ordering"
Fixed. Removed the stack.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9034 c91229c3-7414-0410-bfa2-8a42b809f60b
resources/js/conditional_simple_edit.js
1 1 /* Model Functions
2 2 *
3   - * Perform various and sundry operations on the edit-page.
  3 + * Perform various and sundry operations on the edit-page.
4 4 */
5 5  
6 6  
... ... @@ -44,7 +44,7 @@ function setActiveFields(active_fields) {
44 44 var column = getColumnForField(active_fields[i]);
45 45 setElementClass(column, 'active');
46 46 }
47   -
  47 +
48 48 }
49 49  
50 50 // takes a field, and sets all items in active_lookups to be active. other items are deleted.
... ... @@ -94,17 +94,17 @@ function getActiveLookups() {
94 94 }
95 95 }
96 96 }
97   - }
  97 + }
98 98 return active_lookups;
99 99 }
100 100  
101 101 /** Simple edit: AJAX component */
102 102 // extract the "fixed" field, and identify which fields (if any) are active.
103 103 function updateActiveFields() {
104   -
  104 +
105 105 simpleLog('DEBUG','function updateActiveFields called.');
106 106 var req = getXMLHttpRequest();
107   -
  107 +
108 108 req.open('GET',getTargetUrl()+'?action=updateActiveFields&active_field='+current_fixed, true);
109 109 var deferred = sendXMLHttpRequest(req);
110 110 deferred.addCallback(do_updateActiveFields);
... ... @@ -117,7 +117,7 @@ function do_handleAjaxError(err_source, err) {
117 117  
118 118 // from a selected_lookup, get the fixed_field and pass through, getting the items that selection currently activates.
119 119 function updateActiveLookups(selected_lookup, lookup_label) {
120   -
  120 +
121 121 simpleLog('DEBUG','function updateActiveLookups called.');
122 122 var req = getXMLHttpRequest();
123 123 req.open('GET',getTargetUrl()+'?action=updateActiveLookups&active_field='+current_fixed+'&selected_lookup='+selected_lookup, true);
... ... @@ -127,9 +127,9 @@ function updateActiveLookups(selected_lookup, lookup_label) {
127 127 }
128 128  
129 129 // send a "save" request to the backend, asking it to make the child_lookups the only items parented
130   -// to the selected_lookup (include field_id for selected, and fieldset).
  130 +// to the selected_lookup (include field_id for selected, and fieldset).
131 131 function storeRelationship(selected_lookup, child_lookups) {
132   -
  132 +
133 133 var formKeys = Array();
134 134 var formValues = Array();
135 135  
... ... @@ -170,7 +170,7 @@ function storeRelationship(selected_lookup, child_lookups) {
170 170 // inform the user that something has happened.
171 171 // FIXME this isn't i18n friendly.
172 172 addInformationNote(_('Dependencies saved. (at ') + new Date() + ')');
173   -
  173 +
174 174 deferred.addCallback(do_updateActiveLookups);
175 175 deferred.addErrback(partial(do_handleAjaxError, 'storeRelationship'));
176 176 }
... ... @@ -185,7 +185,7 @@ function addInformationNote(message) {
185 185 var sH = secondHeaders[0];
186 186 contentBox.insertBefore(dynamicMessage, sH);
187 187 }
188   -
  188 +
189 189 var newStr = createDOM('P',null,message);
190 190 replaceChildNodes(dynamicMessage, newStr);
191 191 }
... ... @@ -197,20 +197,20 @@ function do_updateActiveFields(req) {
197 197 var incoming_fields = req.responseXML.getElementsByTagName('active');
198 198 for (var i=0; i<incoming_fields.length; i++) {
199 199 active_fields.push(incoming_fields[i].getAttribute('field_id'));
200   - }
  200 + }
201 201 simpleLog('DEBUG','do_updateActiveFields found active fields: '+repr(active_fields));
202 202 setActiveFields(active_fields);
203 203 }
204 204  
205   -// should receive a simple-enough set of "field" elements,
206   -// filled with "lookup" items.
  205 +// should receive a simple-enough set of "field" elements,
  206 +// filled with "lookup" items.
207 207 function do_updateActiveLookups(label, req) {
208 208 simpleLog('DEBUG','AJAX function do_updateActiveLookups triggered');
209 209 var active_fields = Array();
210 210 var incoming_fields = req.responseXML.getElementsByTagName('field');
211 211 for (var i=0; i<incoming_fields.length; i++) {
212 212 var field = incoming_fields[i];
213   -
  213 +
214 214 var field_id = field.getAttribute('field_id');
215 215 simpleLog('DEBUG','found field: '+field_id);
216 216 var infoset = {'field_id':field_id, 'lookups':new Array()};
... ... @@ -228,7 +228,7 @@ function do_updateActiveLookups(label, req) {
228 228 setActiveLookupsForField(active_fields[i].field_id, active_fields[i].lookups);
229 229 }
230 230 }
231   -
  231 +
232 232 addInformationNote(_('Dependencies for value "')+label+('" loaded.(at ') + new Date() + ')');
233 233 }
234 234  
... ... @@ -253,7 +253,7 @@ function setExclusiveEditing(field_id) {
253 253 var column = getColumnForField(field_id);
254 254 simpleLog('DEBUG','setExclusiveEditing found column' + column + ' for id ' + field_id);
255 255 setElementClass(column, 'active editing');
256   - var item_list = getElementsByTagAndClassName('SELECT','item_list',column)[0]; // FIXME catch potential failure here (pathalogical)
  256 + var item_list = getElementsByTagAndClassName('SELECT','item_list',column)[0]; // FIXME catch potential failure here (pathalogical)
257 257 item_list.multiple = false;
258 258 updateNodeAttributes(item_list, {'onchange':partial(handleChangedSelection, field_id, item_list)});
259 259  
... ... @@ -287,8 +287,8 @@ function saveSimpleField(field_id) {
287 287 if (item_list_select.length == 0) {
288 288 simpleLog('ERROR','no item_list select found in field '+field_id);
289 289 return false;
290   - }
291   - // else
  290 + }
  291 + // else
292 292 var selected_lookup = item_list_select[0].value;
293 293 simpleLog('DEBUG','extracted selected lookup of '+selected_lookup);
294 294  
... ... @@ -318,8 +318,11 @@ function handleChangedSelection(field_id, select_input) {
318 318 var undoStack = Array(); // stores the field_ids.
319 319 var current_fixed = null; // current fixed. saves a bit of time...
320 320 function pushUndoStack(field_id) {
321   - simpleLog('DEBUG','untested function pushUndoStack called.');
322   - if (current_fixed == null) {
  321 + current_fixed = field_id;
  322 + return false;
  323 +
  324 + simpleLog('DEBUG','untested function pushUndoStack called.');
  325 + if (current_fixed == null) {
323 326 current_fixed = field_id;
324 327 return false;
325 328 // pre-initialisation.
... ... @@ -332,23 +335,23 @@ function pushUndoStack(field_id) {
332 335 } else {
333 336 return false; // pass
334 337 }
335   - simpleLog('DEBUG','undoStack is now: '+repr(undoStack));
  338 + simpleLog('DEBUG','undoStack is now: '+repr(undoStack));
336 339 current_fixed=field_id;
337 340 }
338 341  
339   -function popUndoStack() {
340   - simpleLog('DEBUG','function popUndoStack called.');
  342 +function popUndoStack() {
  343 + simpleLog('DEBUG','function popUndoStack called.');
341 344 if (undoStack.length == 0 ) {
342   - simpleLog('ERROR','undo stack popped at 0. This should be impossible');
  345 + simpleLog('ERROR','undo stack popped at 0. This should be impossible');
343 346 return false;
344 347 }
345 348 var targetFixed = undoStack.pop();
346 349 current_fixed = targetFixed;
347 350 setExclusiveEditing(targetFixed);
348   - updateActiveFields(); // trigger an update of the backend.
  351 + updateActiveFields(); // trigger an update of the backend.
349 352 if (undoStack.length == 0) {
350 353 undoStack.push(targetFixed);
351   - simpleLog('ERROR','undo stack popped to 0, re-pushing this last item. ');
  354 + simpleLog('ERROR','undo stack popped to 0, re-pushing this last item. ');
352 355 }
353   - simpleLog('DEBUG','undoStack is now: '+repr(undoStack));
  356 + simpleLog('DEBUG','undoStack is now: '+repr(undoStack));
354 357 }
... ...
templates/ktcore/metadata/conditional/editsimple.smarty
... ... @@ -20,10 +20,10 @@ td { vertical-align: top; }
20 20 .buttonset.inactive { background: transparent; }
21 21  
22 22 .inactive { background: #ccc; }
23   -.inactive .fixed_message,
  23 +.inactive .fixed_message,
24 24 .inactive .unassigned_items,
25 25 .inactive .available_behaviours,
26   -.inactive .behaviour_edit_options
  26 +.inactive .behaviour_edit_options
27 27 {
28 28 display: none;
29 29 }
... ... @@ -61,9 +61,9 @@ addLoadEvent(partial(editSimpleField, {$iMasterFieldId}));
61 61  
62 62 <h2>{i18n}Editing Fieldset Rules (Simple){/i18n}</h2>
63 63  
64   -<p class="descriptiveText">{i18n}To make a value in a <strong>child field</strong> available to the user when another value is
65   -selected in a <strong>parent field</strong>, first ensure that the parent field is being edited (it will have "save" and "done"
66   -as the buttons at the bottom of the column) and then select the value for the parent field. Now select the value(s) in
  64 +<p class="descriptiveText">{i18n}To make a value in a <strong>child field</strong> available to the user when another value is
  65 +selected in a <strong>parent field</strong>, first ensure that the parent field is being edited (it will have "save" and "done"
  66 +as the buttons at the bottom of the column) and then select the value for the parent field. Now select the value(s) in
67 67 the child column(s) you wish to be available to the user when the parent field's value is selected,
68 68 and click "save". Note you that you can use Ctrl-&lt;click&gt; to select multiple child values
69 69 at the same time.{/i18n}</p>
... ... @@ -98,7 +98,7 @@ refresh the page.{/i18n}&lt;/p&gt;
98 98 </div>
99 99 </td>
100 100 {/foreach}
101   -
  101 +
102 102 </tr>
103 103 </tbody>
104 104 <tfoot>
... ... @@ -108,12 +108,9 @@ refresh the page.{/i18n}&lt;/p&gt;
108 108 <div class="form_actions">{capture assign=fid}{$oField->getId()}{/capture}
109 109 {if (!empty($ordering.$fid))}<input type="button" value="{i18n}edit field{/i18n}" class="edit_button" onclick="editSimpleField({$oField->getId()})" />{/if}
110 110 <input type="button" value="{i18n}save this dependency{/i18n}" class="save_button" onclick="saveSimpleField({$oField->getId()})" />
111   - {if ($iMasterFieldId != $oField->getId())} {* Only for non-initial fields. *}
112   - <input type="button" value="{i18n}finished with this field{/i18n}" class="done_button" onclick="finishSimpleField({$oField->getId()})" />
113   - {/if}
114 111 </div>
115 112 </td>
116   -{/foreach}
  113 +{/foreach}
117 114 </tr>
118 115 </tfoot>
119 116 </table>
... ...