Commit c2672dfe5aba1683fb9187777e5ecf6f5a618736
1 parent
36f1019e
Templates for simple conditional metadata editing
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3701 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
6 changed files
with
549 additions
and
0 deletions
templates/ktcore/metadata/conditional/ajax_masterfield.smarty
0 → 100644
templates/ktcore/metadata/conditional/ajax_subfield.smarty
0 → 100644
| 1 | +<!-- direct values --> | ||
| 2 | +<div class="formSelection"> | ||
| 3 | +<select multiple="true" name="direct_values_{$field_id}[]"> | ||
| 4 | + {foreach item=aLookupRow from=$lookups} | ||
| 5 | + <option value="{$aLookupRow.lookup_id}">{$aLookupRow.lookup_val}</option> | ||
| 6 | + {/foreach} | ||
| 7 | +</select> | ||
| 8 | + | ||
| 9 | +<!-- subtree's selectable for this field --> | ||
| 10 | +{if (!empty($rulesets))} | ||
| 11 | + {foreach item=ruleset from=$rulesets} | ||
| 12 | + <input type="checkbox" name="rulesets_to_attach[]" value="{$ruleset.rule_id}">{$ruleset.rule_name}</input><br /> | ||
| 13 | + {/foreach} | ||
| 14 | +{else} | ||
| 15 | +<p>No rulesets for this field.</p> | ||
| 16 | +{/if} | ||
| 17 | + | ||
| 18 | +<p><a href="/presentation/lookAndFeel/knowledgeTree/administration/conditionalmanagement/manageConditionals.php?action=newSubConditionSet&fieldset_id={$fieldset_id}&starting_field={$field_id}">add a ruleset</a>.</p> | ||
| 19 | +</div> |
templates/ktcore/metadata/conditional/editsimple.smarty
0 → 100644
| 1 | +{literal} | ||
| 2 | +<style> | ||
| 3 | + | ||
| 4 | +.active { | ||
| 5 | + background: transparent; | ||
| 6 | +} | ||
| 7 | + | ||
| 8 | +.inactive { | ||
| 9 | + background: #ccc; | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +.inactive .fieldselection { | ||
| 13 | + display: none; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +.currentmaster .editbutton { display: none; } | ||
| 17 | +.savebutton { display: none; } | ||
| 18 | +.currentmaster .savebutton { display: block; } | ||
| 19 | +.active .activity_message { display: none; } | ||
| 20 | +.inactive .savebutton { display: none; } | ||
| 21 | + | ||
| 22 | +</style> | ||
| 23 | + | ||
| 24 | +<!-- include the mochikit js --> | ||
| 25 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Base.js"> </script> | ||
| 26 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Iter.js"> </script> | ||
| 27 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Async.js"> </script> | ||
| 28 | +<script language="javascript" src="/thirdpartyjs/MochiKit/DOM.js"> </script> | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +<!-- custom JS --> | ||
| 34 | + | ||
| 35 | +<script language="javascript"> | ||
| 36 | + | ||
| 37 | +function str_startswith(source, contents) { | ||
| 38 | + var clen = contents.length; | ||
| 39 | + if (source.length < clen) { | ||
| 40 | + return false; | ||
| 41 | + } else { | ||
| 42 | + var matcher = source.substr(0, clen); | ||
| 43 | + if (matcher == contents) { | ||
| 44 | + return true; | ||
| 45 | + } else { | ||
| 46 | + return false; | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +/* | ||
| 53 | + * Basic workflow on this page is incredibly simple. | ||
| 54 | + * At each stage there is: | ||
| 55 | + * 1. an "active" set of fields | ||
| 56 | + * 2. an "inactive" set of fields. | ||
| 57 | + * | ||
| 58 | + * Essentially, the backend needs to provide a limited set | ||
| 59 | + * of operations: | ||
| 60 | + * 1. Save a selection (active sets) | ||
| 61 | + * 2. Edit a new "master column". | ||
| 62 | + */ | ||
| 63 | + | ||
| 64 | +/* | ||
| 65 | + * function saveSimpleEditSelection(); | ||
| 66 | + * | ||
| 67 | + * 1. find all "active" columns, and which field is "master". | ||
| 68 | + * 2. create the "save" request (question: how do we build a POST ... the GET is now too long, since IE dies past 1024 chars (or is it 256?) | ||
| 69 | + * 3. submit. | ||
| 70 | + */ | ||
| 71 | +function saveSimpleEditSelection (save_button) { | ||
| 72 | + var formKeys = Array(); | ||
| 73 | + var formValues = Array(); | ||
| 74 | + // these need to be "pushed" simultanously. | ||
| 75 | + var activeColumns = getElementsByTagAndClassName("td","active"); | ||
| 76 | + | ||
| 77 | + /* the submitted form has a simple set of variables. | ||
| 78 | + * | ||
| 79 | + * fields[][] - two-dimensional array: | ||
| 80 | + * [field_id] => [array(active values)]. | ||
| 81 | + * fieldset_id - integer fieldset id. | ||
| 82 | + * | ||
| 83 | + * master_field - integer master-field id. | ||
| 84 | + */ | ||
| 85 | + | ||
| 86 | + formKeys.push('action'); | ||
| 87 | + formValues.push('saveSimpleEdit'); | ||
| 88 | + for (index in activeColumns) { | ||
| 89 | + var t = DIV(null); | ||
| 90 | + var obj = activeColumns[index]; | ||
| 91 | + if (typeof(obj) == typeof(t)) { | ||
| 92 | + var oclass = obj.getAttribute('class'); | ||
| 93 | + var oid = obj.getAttribute('id'); | ||
| 94 | + | ||
| 95 | + // we can extract the field name from this quite simply | ||
| 96 | + // by removing | ||
| 97 | + var cs_len = 'contain_select_'.length; | ||
| 98 | + if (str_startswith(oid, 'contain_select_')) { | ||
| 99 | + var str_end = oid.substr(cs_len, oid.length); | ||
| 100 | + formKeys.push('fields[]'); | ||
| 101 | + formValues.push(str_end); | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + // FIXME handle Trees. | ||
| 105 | + | ||
| 106 | + // since we are active, we can also get the select. | ||
| 107 | + var selection = getElementsByTagAndClassName("select","fieldselection", obj); | ||
| 108 | + // MUST be only 1. | ||
| 109 | + if (selection.length != 0) { | ||
| 110 | + var selObj = selection[0]; | ||
| 111 | + var key = 'fields['+str_end+'][]'; | ||
| 112 | + // there can be multiple matches here. | ||
| 113 | + for (selindex in selObj.options) { | ||
| 114 | + var subobj = selObj.options[selindex]; | ||
| 115 | + if (typeof(subobj) == typeof(t)) { | ||
| 116 | + if (subobj.selected) { | ||
| 117 | + formKeys.push(key); | ||
| 118 | + formValues.push(subobj.value); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + // handle the case where this is a buttongroup - find the "master". | ||
| 124 | + } else { | ||
| 125 | + if (hasElementClass(obj, 'currentmaster')) { | ||
| 126 | + var cs_len = 'contain_buttons_'.length; | ||
| 127 | + var str_end = oid.substr(cs_len, oid.length); | ||
| 128 | + formKeys.push('master_field'); | ||
| 129 | + formValues.push(str_end); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + // finally. | ||
| 135 | + var POSTval = queryString(formKeys, formValues); | ||
| 136 | + | ||
| 137 | + var targeturl = 'manageConditionals.php'; | ||
| 138 | + var req = getXMLHttpRequest(); | ||
| 139 | + req.open("POST", targeturl, true); | ||
| 140 | + req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); | ||
| 141 | + var deferred = sendXMLHttpRequest(req, POSTval); | ||
| 142 | + deferred.addCallback(partial(do_saveSimpleRelation, save_button)); | ||
| 143 | + deferred.addErrback(partial(do_handleAjaxError, save_button, | ||
| 144 | +'save')); | ||
| 145 | + // indicate to the user that we are saved. | ||
| 146 | + save_button.disabled = true; | ||
| 147 | + save_button.value = "saving..."; | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +// intentionally stubbed - we don't actually act here. | ||
| 151 | +// at most we need a "kill saving". | ||
| 152 | +function do_saveSimpleRelation(button, req) { | ||
| 153 | + //alert('saved '+req.responseText); | ||
| 154 | + button.disabled = false; | ||
| 155 | + button.value = "save"; | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +function do_handleAjaxError(button, button_val, err) { | ||
| 159 | + alert('failed while trying to '+button_val); | ||
| 160 | + button.disabled = false; | ||
| 161 | + button.value = button_val; | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +function getSubSelect(obj) { | ||
| 165 | + return getElementsByTagAndClassName('select','fieldselection', obj); | ||
| 166 | +} | ||
| 167 | +/* | ||
| 168 | + * function editNewSimpleSelection(int field_id) | ||
| 169 | + * | ||
| 170 | + * 1. initiate an XMLHTTPRequest to get the "controlled fields". | ||
| 171 | + * 2. change all to be either "active" or "inactive" | ||
| 172 | + * 3. add "save" to the appropriate column. | ||
| 173 | + * | ||
| 174 | + */ | ||
| 175 | +function editNewSimpleSelection(field_id) { | ||
| 176 | + var active_fields = Array(); | ||
| 177 | + // DEBUG CODE | ||
| 178 | + if (field_id == '8') { | ||
| 179 | + active_fields.push('8'); | ||
| 180 | + active_fields.push('9'); | ||
| 181 | + } else { | ||
| 182 | + active_fields.push('5'); | ||
| 183 | + active_fields.push('8'); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + var edit_columns = getElementsByTagAndClassName('td','editable'); | ||
| 187 | + var button_columns = getElementsByTagAndClassName('td','buttons'); | ||
| 188 | + | ||
| 189 | + for (var i=0; i<edit_columns.length; i++) { | ||
| 190 | + var obj = edit_columns[i]; | ||
| 191 | + var cs_len = 'contain_select_'.length; // horrid. | ||
| 192 | + var col_num = obj.id.substr(cs_len, obj.id.length); | ||
| 193 | + | ||
| 194 | + setElementClass(obj, 'inactive editable'); | ||
| 195 | + // sigh. we want to know if this is "active" ... | ||
| 196 | + for (var j=0; j<active_fields.length; j++) | ||
| 197 | + { | ||
| 198 | + if (col_num == active_fields[j]) { | ||
| 199 | + setElementClass(obj, 'active editable'); | ||
| 200 | + // urgh. we now need to set the master column's select to not be multiple. | ||
| 201 | + var slist = getSubSelect(obj); | ||
| 202 | + for (var k=0; k<slist.length; k++) { | ||
| 203 | + if (col_num == field_id) { | ||
| 204 | + slist[k].multiple = false; | ||
| 205 | + } else { | ||
| 206 | + slist[k].multiple = true; | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + for (var i=0; i<button_columns.length; i++) { | ||
| 214 | + var obj = button_columns[i]; | ||
| 215 | + var cs_len = 'contain_buttons_'.length; // horrid. | ||
| 216 | + var col_num = obj.id.substr(cs_len, obj.id.length); | ||
| 217 | + | ||
| 218 | + setElementClass(obj, 'inactive buttons'); | ||
| 219 | + // sigh. we want to know if this is "active" ... | ||
| 220 | + for (var j=0; j<active_fields.length; j++) | ||
| 221 | + { | ||
| 222 | + if (col_num == active_fields[j]) { | ||
| 223 | + if (col_num == field_id) { | ||
| 224 | + setElementClass(obj, 'active buttons currentmaster'); | ||
| 225 | + } else { | ||
| 226 | + setElementClass(obj, 'active buttons'); | ||
| 227 | + } | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +function getMasterField() { | ||
| 234 | + var cols = getElementsByTagAndClassName('td','buttons'); | ||
| 235 | + var mf = null; | ||
| 236 | + for (var i=0; i<cols.length; i++) { | ||
| 237 | + var c = cols[i]; | ||
| 238 | + if (hasElementClass(c, 'currentmaster')) { | ||
| 239 | + mf = c.id.substr('contain_buttons_'.length,c.id.length); | ||
| 240 | + } | ||
| 241 | + } | ||
| 242 | + return mf; | ||
| 243 | +} | ||
| 244 | + | ||
| 245 | +/* function getExistingFieldsForVal | ||
| 246 | + * | ||
| 247 | + * FIXME we need to add XML function here. | ||
| 248 | + */ | ||
| 249 | +function getExistingFieldsForVal(field_id) { | ||
| 250 | + // DEBUG | ||
| 251 | + if ((getMasterField() == field_id) && (field_id == "1")) { | ||
| 252 | + alert('updating selections'); | ||
| 253 | + var preoptions = Array(); | ||
| 254 | + | ||
| 255 | + // 1 get the value for field field_id. | ||
| 256 | + var f = getElement('sel_'+field_id); | ||
| 257 | + var active_val = f.value; // this is the active value of the field. | ||
| 258 | + | ||
| 259 | + // 2 fetch the option-array. this should be a list of "<opt num="3" active="{1,0}" /> | ||
| 260 | + // DEBUG HACK. | ||
| 261 | + availcols = Array(); | ||
| 262 | + availcols.push("2"); | ||
| 263 | + availcols.push("3"); | ||
| 264 | + preoptions["2"] = Array(); | ||
| 265 | + preoptions["3"] = Array(); | ||
| 266 | + preoptions["2"]["4"] = true; | ||
| 267 | + preoptions["2"]["5"] = true; | ||
| 268 | + preoptions["2"]["6"] = false; | ||
| 269 | + preoptions["3"]["7"] = true; | ||
| 270 | + preoptions["3"]["8"] = false; | ||
| 271 | + preoptions["3"]["9"] = true; | ||
| 272 | + | ||
| 273 | + // 3 get and update from the preoption array | ||
| 274 | + // to do this, grab the "sel" and walk its options. | ||
| 275 | + for (var i=0; i<availcols.length; i++) { | ||
| 276 | + var colid = availcols[i]; | ||
| 277 | + var selid = 'sel_'+colid; | ||
| 278 | + var selection = getElement(selid); | ||
| 279 | + for (var k=0; k<selection.options.length; k++) { | ||
| 280 | + selection.options[k].selected = preoptions[colid][selection.options[k].value]; | ||
| 281 | + } | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | +} | ||
| 286 | + | ||
| 287 | +</script> | ||
| 288 | + | ||
| 289 | +{/literal} | ||
| 290 | + | ||
| 291 | + | ||
| 292 | +<h2>Editing Fieldset Rules (Simple)</h2> | ||
| 293 | + | ||
| 294 | +<!-- by default, we start by editing the _first_ column. | ||
| 295 | + after that, we need to update / get the "active columns" ids. --> | ||
| 296 | + | ||
| 297 | +<table> | ||
| 298 | + <tr> | ||
| 299 | +{foreach from=$aFields item=oField} | ||
| 300 | + <th><span title="Field {$oField->getId()}">{$oField->getName()}</span></th> | ||
| 301 | +{/foreach} | ||
| 302 | + </tr> | ||
| 303 | + <tr valign="top"> | ||
| 304 | + | ||
| 305 | +{foreach from=$aFields item=oField} | ||
| 306 | +{assign var=sMultiple value=""} | ||
| 307 | +{assign var="sActive" value="inactive"} | ||
| 308 | +{if $oField->getParentFieldId()} | ||
| 309 | + {assign var=sMultiple value='multiple="true"'} | ||
| 310 | + {if $oField->getParentFieldId() == $iMasterFieldId} | ||
| 311 | + {assign var="sActive" value="active"} | ||
| 312 | + {/if} | ||
| 313 | +{else} | ||
| 314 | + {assign var="sActive" value="active"} | ||
| 315 | +{/if} | ||
| 316 | + <td class="{$sActive} editable" id="contain_select_{$oField->getId()}"> | ||
| 317 | + <p class="activity_message">This field is not controlled by the currently active group.</p> | ||
| 318 | + <select name="column_{$oField->getId()}" {$sMultiple} class="fieldselection" id="sel_{$oField->getId()}" onchange="getExistingFieldsForVal({$oField->getId()});"> | ||
| 319 | + | ||
| 320 | + {foreach from=$oField->getValues() item=oMetaData} | ||
| 321 | + <option value="{$oMetaData->getId()}">{$oMetaData->getName()|escape}</option> | ||
| 322 | + {/foreach} | ||
| 323 | + </select> | ||
| 324 | + </td> | ||
| 325 | +{/foreach} | ||
| 326 | + </tr> | ||
| 327 | + <tr> | ||
| 328 | + | ||
| 329 | +{foreach from=$aFields item=oField} | ||
| 330 | + | ||
| 331 | +{assign var="sActive" value="inactive"} | ||
| 332 | +{if $oField->getParentFieldId()} | ||
| 333 | + {assign var=sMultiple value='multiple="true"'} | ||
| 334 | + {if $oField->getParentFieldId() == $iMasterFieldId} | ||
| 335 | + {assign var="sActive" value="active"} | ||
| 336 | + {/if} | ||
| 337 | +{else} | ||
| 338 | + {assign var="sActive" value="active currentmaster"} | ||
| 339 | +{/if} | ||
| 340 | + | ||
| 341 | +<td class="{$sActive} buttons" id="contain_buttons_{$oField->getId()}"> | ||
| 342 | + {if $oField->hasChildren()} | ||
| 343 | + <input type="button" onclick="editNewSimpleSelection({$oField->getId()});" value="Edit" class="editbutton" /> | ||
| 344 | + | ||
| 345 | + <input type="button" onclick="saveSimpleEditSelection(this);" value="Save" class="savebutton" /> | ||
| 346 | + {/if} | ||
| 347 | +</td> | ||
| 348 | +{/foreach} | ||
| 349 | + </tr> | ||
| 350 | +</table> |
templates/ktcore/metadata/conditional/manageConditional.smarty
0 → 100644
| 1 | +<h1>Manage conditional fieldset<h1> | ||
| 2 | + | ||
| 3 | +<h2>Field ordering</h2> | ||
| 4 | + | ||
| 5 | +{if $aFieldOrders} | ||
| 6 | +<h3>Existing ordering</h2> | ||
| 7 | + | ||
| 8 | +<ul> | ||
| 9 | +{foreach from=$aFieldOrders item=aRow} | ||
| 10 | +{php} | ||
| 11 | +$this->assign("oParentField", DocumentField::get($this->_tpl_vars['aRow']['parent_field_id'])); | ||
| 12 | +$this->assign("oChildField", DocumentField::get($this->_tpl_vars['aRow']['child_field_id'])); | ||
| 13 | +{/php} | ||
| 14 | + <li> | ||
| 15 | +<span title="Field Id {$oParentField->getId()}">Field {$oParentField->getName()|escape}</span> | ||
| 16 | +affects the values available in | ||
| 17 | +<span title="Field Id {$oChildField->getId()}">field {$oChildField->getName()|escape}</span> | ||
| 18 | +</li> | ||
| 19 | +{/foreach} | ||
| 20 | +</ul> | ||
| 21 | +{/if} | ||
| 22 | + | ||
| 23 | +<h3>Order fields</h2> | ||
| 24 | + | ||
| 25 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | ||
| 26 | +<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | ||
| 27 | +<input type="hidden" name="action" value="orderFields"> | ||
| 28 | + | ||
| 29 | +The available values of the selected fields: | ||
| 30 | +<br /> | ||
| 31 | +{entity_select entities=$free_fields name="fFreeFieldIds[]" multiple="yes"} | ||
| 32 | +<br /> | ||
| 33 | +are conditional on the values of this field: | ||
| 34 | +<br /> | ||
| 35 | +{entity_select entities=$parent_fields name="fParentFieldId"} | ||
| 36 | +<br /> | ||
| 37 | +<input type="submit" name="submit" value="Order"> | ||
| 38 | +</form> |
templates/ktcore/metadata/conditional/new_masterset.smarty
0 → 100644
| 1 | +<!-- we REALLY NEED that new ui component. --> | ||
| 2 | + | ||
| 3 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Base.js"> </script> | ||
| 4 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Iter.js"> </script> | ||
| 5 | +<script language="javascript" src="/thirdpartyjs/MochiKit/DOM.js"> </script> | ||
| 6 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Async.js"> </script> | ||
| 7 | +{literal} | ||
| 8 | +<script language="javascript"> | ||
| 9 | + | ||
| 10 | +var destination="/presentation/lookAndFeel/knowledgeTree/administration/conditionalmanagement/ajaxConditionals.php"; | ||
| 11 | + | ||
| 12 | +{/literal} | ||
| 13 | +var fieldset="{$fieldset_id}"; | ||
| 14 | +{literal} | ||
| 15 | + | ||
| 16 | +// try to re-create our url, for the XML HTTPREQ to work. | ||
| 17 | +function constructURL() { | ||
| 18 | +{/literal} | ||
| 19 | + var https = "{$smarty.server.HTTPS}"; | ||
| 20 | + var host = "{$smarty.server.HTTP_HOST}"; | ||
| 21 | +{literal} | ||
| 22 | + var d = ""; | ||
| 23 | + if (https == "") { d = "http://"; } | ||
| 24 | + else { d = "https://"; } | ||
| 25 | + | ||
| 26 | + d = d + host + destination; | ||
| 27 | + return d; | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +function swapInMasterColumn(req) { | ||
| 31 | + var newinfo = req.responseText; | ||
| 32 | + var repl = getElement("master_field_column"); | ||
| 33 | + repl.innerHTML = newinfo; | ||
| 34 | + | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +function xmlFailure(err) { | ||
| 38 | + alert('failed to obtain the appropriate data..'); | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +var fetching = null; | ||
| 42 | + | ||
| 43 | +function getFieldInfoAndAdd(req) { | ||
| 44 | + // find the inner val. | ||
| 45 | + var cp = getElement(fetching); | ||
| 46 | + //alert(fetching); | ||
| 47 | + //alert(cp); | ||
| 48 | + cp.innerHTML = req.responseText; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +function manageOptions(is_active, parentNode, field_id) { | ||
| 52 | + if (!is_active) { | ||
| 53 | + // delete any options. | ||
| 54 | + //alert(field_id); | ||
| 55 | + var targets = getElement("checkpoint"+field_id).childNodes; | ||
| 56 | + //alert(parentNode); | ||
| 57 | + for (var i=0; i<targets.length; i++) | ||
| 58 | + targets[i].parentNode.removeChild(targets[i]); | ||
| 59 | + | ||
| 60 | + } else { | ||
| 61 | + // fetch and add to parentNode. | ||
| 62 | + fetching = "checkpoint"+field_id; | ||
| 63 | + | ||
| 64 | + var masterColumnGet="?action=getFieldFromSet&fieldset_id="+fieldset+"&field_id="+field_id; | ||
| 65 | + var fullUrl = constructURL()+masterColumnGet; | ||
| 66 | + var deff = doSimpleXMLHttpRequest(fullUrl); | ||
| 67 | + deff.addCallback(getFieldInfoAndAdd); | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +function removeFieldSelection(parentNode) { | ||
| 74 | + //alert('toasting...'); | ||
| 75 | + // remove a formFields element from the set. | ||
| 76 | + var selections = getElementsByTagAndClassName('select','formFields',parentNode); | ||
| 77 | + for (var i=0; i<selections.length; i++) | ||
| 78 | + selections[i].parentNode.removeChild(selections[i]); | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +function getMasterColumn() { | ||
| 82 | + var masterColumnGet="?action=getMasterFieldForSet&fieldset_id="+fieldset; | ||
| 83 | + var fullUrl = constructURL()+masterColumnGet; | ||
| 84 | + // now | ||
| 85 | + var deff = doSimpleXMLHttpRequest(fullUrl); | ||
| 86 | + | ||
| 87 | + deff.addCallback(swapInMasterColumn); | ||
| 88 | + deff.addErrback(xmlFailure); | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +addLoadEvent(getMasterColumn); | ||
| 92 | + | ||
| 93 | +</script> | ||
| 94 | +{/literal} | ||
| 95 | +<h1>Impose conditions on Fieldset</h1> | ||
| 96 | + | ||
| 97 | +<form> | ||
| 98 | +<input type="hidden" name="action" value="createMasterChain" /> | ||
| 99 | +<input type="hidden" name="fieldset_id" value="{$fieldset_id}" /> | ||
| 100 | + | ||
| 101 | + | ||
| 102 | +<table id="conditional_table"> | ||
| 103 | +<tr valign="top"> | ||
| 104 | + <td><span id="master_field_column">loading free items</span></td> | ||
| 105 | + {foreach item=aFieldRow from=$other_fields} | ||
| 106 | + <td> | ||
| 107 | + <input type="checkbox" name="fields_to_attach[]" value="{$aFieldRow->getId()}" onchange="manageOptions(this.checked, this.parentNode, this.value);">Control {$aFieldRow->getName()}</input> | ||
| 108 | + <div id="checkpoint{$aFieldRow->getId()}"> </div> | ||
| 109 | + </td> | ||
| 110 | + {/foreach} | ||
| 111 | +</tr> | ||
| 112 | +</table> | ||
| 113 | + | ||
| 114 | + | ||
| 115 | +<input type="submit" value="save" /> | ||
| 116 | +</form> | ||
| 117 | + | ||
| 118 | + |
templates/ktcore/metadata/conditional/select_fieldset.smarty
0 → 100644
| 1 | +<h2>Select Fieldset</h2> | ||
| 2 | + | ||
| 3 | +<form> | ||
| 4 | +<fieldset> | ||
| 5 | +<legend>Current Conditional Fieldsets</legend> | ||
| 6 | +<p>Fieldsets that are marked as conditional.</p> | ||
| 7 | + | ||
| 8 | +<input type="hidden" name="action" value="editFieldset" /> | ||
| 9 | + | ||
| 10 | +{foreach item=oFieldSet from=$available_fieldsets} | ||
| 11 | + <input type="radio" name="fieldset_id" value="{$oFieldSet->getId()}">{$oFieldSet->getName()}</input> | ||
| 12 | +{/foreach} | ||
| 13 | + | ||
| 14 | +<div> | ||
| 15 | +<input type="submit" name="submit" value="Edit"> | ||
| 16 | +</div> | ||
| 17 | +</fieldset> | ||
| 18 | +</form> |