Commit 86f5582b16ed2fd23df97e11c2307daf65d4e048
1 parent
125ce16a
"Complex" conditional metadata: Ajax stubs.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3743 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
252 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/conditional/ajaxComplexConditionals.php
0 → 100644
| 1 | +<?php | ||
| 2 | +require_once("../../../../../../config/dmsDefaults.php"); | ||
| 3 | +require_once(KT_DIR . "/presentation/Html.inc"); | ||
| 4 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 5 | +require_once(KT_LIB_DIR . "/documentmanagement/DocumentField.inc"); | ||
| 6 | +require_once(KT_LIB_DIR . "/database/dbutil.inc"); | ||
| 7 | +require_once(KT_LIB_DIR . "/util/ktutil.inc"); | ||
| 8 | +require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | ||
| 9 | +$sectionName = "Administration"; | ||
| 10 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | ||
| 11 | +require_once(KT_LIB_DIR . "/metadata/fieldset.inc.php"); | ||
| 12 | + | ||
| 13 | +class AjaxConditionalAdminDispatcher extends KTDispatcher { | ||
| 14 | + function do_main() { | ||
| 15 | + return "Ajax Error: no action specified."; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + // a lot simpler than the standard dispatcher, this DOESN'T include a large amount of "other" stuff ... we are _just_ called to handle | ||
| 19 | + // input/output of simple HTML components. | ||
| 20 | + function handleOutput($data) { | ||
| 21 | + print $data; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** lookup methods. */ | ||
| 25 | + | ||
| 26 | + // get the list of free items for a given column, under a certain parent behaviour. | ||
| 27 | + function do_getItemList() { | ||
| 28 | + $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour'); | ||
| 29 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); // | ||
| 30 | + $field_id = KTUtil::arrayGet($_REQUEST, 'field_id'); | ||
| 31 | + | ||
| 32 | + header('Content-type: application/xml'); | ||
| 33 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 34 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_get_item_list'); | ||
| 35 | + return $oTemplate->render(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + function do_getBehaviourList() { | ||
| 39 | + $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour'); | ||
| 40 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 41 | + $field_id = KTUtil::arrayGet($_REQUEST, 'field_id'); | ||
| 42 | + | ||
| 43 | + header('Content-type: application/xml'); | ||
| 44 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 45 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_get_behaviour_list'); | ||
| 46 | + return $oTemplate->render(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + function do_getActiveFields() { | ||
| 50 | + $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour'); | ||
| 51 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); // | ||
| 52 | + | ||
| 53 | + header('Content-type: application/xml'); | ||
| 54 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 55 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_get_active_fields'); | ||
| 56 | + return $oTemplate->render(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** storage methods */ | ||
| 60 | + function do_createBehaviourAndAssign() { | ||
| 61 | + $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour'); | ||
| 62 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 63 | + $field_id = KTUtil::arrayGet($_REQUEST, 'field_id'); | ||
| 64 | + $behaviour_name = KTUtil::arrayGet($_REQUEST, 'behaviour_name'); | ||
| 65 | + $lookups_to_assign = KTUtil::arrayGet($_REQUEST, 'lookups_to_assign'); // array | ||
| 66 | + | ||
| 67 | + header('Content-type: application/xml'); | ||
| 68 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 69 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_create_behaviour_and_assign'); | ||
| 70 | + return $oTemplate->render(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + function do_useBehaviourAndAssign() { | ||
| 74 | + $parent_behaviour = KTUtil::arrayGet($_REQUEST, 'parent_behaviour'); | ||
| 75 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 76 | + $field_id = KTUtil::arrayGet($_REQUEST, 'field_id'); | ||
| 77 | + $behaviour_name = KTUtil::arrayGet($_REQUEST, 'behaviour_id'); | ||
| 78 | + $lookups_to_assign = KTUtil::arrayGet($_REQUEST, 'lookups_to_assign'); // array | ||
| 79 | + | ||
| 80 | + header('Content-type: application/xml'); | ||
| 81 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 82 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/metadata/conditional/ajax_complex_use_behaviour_and_assign'); | ||
| 83 | + return $oTemplate->render(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +$oDispatcher = new AjaxConditionalAdminDispatcher(); | ||
| 90 | +$oDispatcher->dispatch(); | ||
| 91 | + | ||
| 92 | +?> |
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/conditional/manageConditionals.php
| @@ -48,6 +48,29 @@ class ManageConditionalDispatcher extends KTStandardDispatcher { | @@ -48,6 +48,29 @@ class ManageConditionalDispatcher extends KTStandardDispatcher { | ||
| 48 | ); | 48 | ); |
| 49 | return $oTemplate->render($aTemplateData); | 49 | return $oTemplate->render($aTemplateData); |
| 50 | } | 50 | } |
| 51 | + | ||
| 52 | + // FIXME refactor this into do_editSimple(fieldset_id); | ||
| 53 | + function do_editComplexFieldset() { | ||
| 54 | + $fieldset_id = KTUtil::arrayGet($_REQUEST, "fieldset_id"); | ||
| 55 | + $oTemplating = new KTTemplating; | ||
| 56 | + $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/conditional/editcomplex"); | ||
| 57 | + /* alright: to "do" this we need at least: | ||
| 58 | + * 1. the list of all the columns (id, name) and their available values. | ||
| 59 | + * 2. the fieldset_id. | ||
| 60 | + * we can then render in/out. Everything "intelligent" happens | ||
| 61 | + * in AJAX (doing it with submits sucks arse. | ||
| 62 | + * | ||
| 63 | + * FIXME we fake it here with nested arrays... | ||
| 64 | + */ | ||
| 65 | + $oFieldset =& KTFieldset::get($fieldset_id); | ||
| 66 | + $aFields =& $oFieldset->getFields(); | ||
| 67 | + $aTemplateData = array( | ||
| 68 | + "fieldset_id" => $fieldset_id, | ||
| 69 | + "aFields" => $aFields, | ||
| 70 | + "iMasterFieldId" => $aFields[0]->getId(), | ||
| 71 | + ); | ||
| 72 | + return $oTemplate->render($aTemplateData); | ||
| 73 | + } | ||
| 51 | 74 | ||
| 52 | 75 | ||
| 53 | 76 |
templates/ktcore/metadata/conditional/ajax_complex_create_behaviour_and_assign.smarty
0 → 100644
templates/ktcore/metadata/conditional/ajax_complex_get_active_fields.smarty
0 → 100644
templates/ktcore/metadata/conditional/ajax_complex_get_behaviour_list.smarty
0 → 100644
templates/ktcore/metadata/conditional/ajax_complex_get_item_list.smarty
0 → 100644
templates/ktcore/metadata/conditional/ajax_complex_use_behaviour_and_assign.smarty
0 → 100644
templates/ktcore/metadata/conditional/editcomplex.smarty
0 → 100644
| 1 | +{literal} | ||
| 2 | +<style type="text/css"> | ||
| 3 | +/* inactivity */ | ||
| 4 | +.active .inactivity_message { display: none; } | ||
| 5 | + | ||
| 6 | +/* fixed status */ | ||
| 7 | +.active .fixed_message { display: none; } | ||
| 8 | +.active.fixed .fixed_message { display: block; } | ||
| 9 | +.active.fixed .unassigned_items { display: none; } | ||
| 10 | + | ||
| 11 | +.inactive { background: #ccc; } | ||
| 12 | +.inactive .fixed_message, | ||
| 13 | +.inactive .unassigned_items, | ||
| 14 | +.inactive .available_behaviours, | ||
| 15 | +.inactive .behaviour_edit_options | ||
| 16 | +{ display: none; } | ||
| 17 | + | ||
| 18 | +.helpText { color: #666; } | ||
| 19 | + | ||
| 20 | +</style> | ||
| 21 | + | ||
| 22 | +<!-- include the mochikit js --> | ||
| 23 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Base.js"> </script> | ||
| 24 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Iter.js"> </script> | ||
| 25 | +<script language="javascript" src="/thirdpartyjs/MochiKit/DateTime.js"> </script> | ||
| 26 | +<script language="javascript" src="/thirdpartyjs/MochiKit/Async.js"> </script> | ||
| 27 | +<script language="javascript" src="/thirdpartyjs/MochiKit/DOM.js"> </script> | ||
| 28 | + | ||
| 29 | +<script language="javascript" src="/presentation/lookAndFeel/knowledgeTree/js/taillog.js"> </script> | ||
| 30 | +<script language="javascript" src="/presentation/lookAndFeel/knowledgeTree/js/conditional_complex_edit.js"> </script> | ||
| 31 | + | ||
| 32 | +<script language="javascript"> | ||
| 33 | +addLoadEvent(updateActiveFields); | ||
| 34 | +</script> | ||
| 35 | + | ||
| 36 | +{/literal} | ||
| 37 | + | ||
| 38 | +<h2>Edit Complex Conditional Metadata</h2> | ||
| 39 | +<form> | ||
| 40 | +<input type="hidden" name="fieldset_id" id="global-fieldset-id" value="{$fieldset_id}" /> | ||
| 41 | + | ||
| 42 | +<table> | ||
| 43 | +<!-- | ||
| 44 | +<tr> | ||
| 45 | + <th>Column 1</th> | ||
| 46 | + <th>Column 2</th> | ||
| 47 | + <th>Column 3</th> | ||
| 48 | + <th>Column 4</th> | ||
| 49 | +</tr> --> | ||
| 50 | +<tbody> | ||
| 51 | +<tr valign="top"> | ||
| 52 | +{foreach from=$aFields item=oField} | ||
| 53 | + <td class="inactive" id="md_{$oField->getId()}"> | ||
| 54 | + <h3>{$oField->getName()}</h3> | ||
| 55 | + <p class="inactivity_message">This column is not active.</p> | ||
| 56 | + <p class="fixed_message">Editing behaviour <strong>Jack</strong></p> | ||
| 57 | + <div class="unassigned_items"> | ||
| 58 | + <h3>Unassigned/Unavailable</h3> | ||
| 59 | + <select class="item_list" multiple="true"> | ||
| 60 | + <!-- These are orphaned - we fire a "activate" command on load / available. | ||
| 61 | + <option value="-1">Test 1</option> | ||
| 62 | + <option value="-2">Test 2</option> | ||
| 63 | + <option value="-3">Test 3</option> | ||
| 64 | + <option value="-4">Test 4</option> | ||
| 65 | + --> | ||
| 66 | + </select> | ||
| 67 | + <p><strong>Assign to behaviour</strong></p> | ||
| 68 | + <select class="available_behaviours" onchange="assignToBehaviour(this, {$oField->getId()});"> | ||
| 69 | + <option>Select a behaviour</option> | ||
| 70 | + <!-- ditto | ||
| 71 | + <option value="1">Behaviour 1</option> | ||
| 72 | + <option value="2">Behaviour 2</option> | ||
| 73 | + <option value="3">Behaviour 3</option> | ||
| 74 | + <option value="4">Behaviour 4</option> | ||
| 75 | + --> | ||
| 76 | + </select> <br /> | ||
| 77 | + <strong>or</strong> to a new behaviour called <br /> | ||
| 78 | + <input type="text" name="new_behaviour" class="new_behaviour" /> | ||
| 79 | + <input type="button" value="create behaviour" onclick="assignToNewBehaviour({$oField->getId()});" /> | ||
| 80 | + </div> | ||
| 81 | + <div class="behaviour_edit_options"> | ||
| 82 | + <h3>Edit Behaviour</h3> | ||
| 83 | + <p class="helpText"> | ||
| 84 | + Select a behaviour from this list to change the | ||
| 85 | + items which are available. | ||
| 86 | + </p> | ||
| 87 | + <select class="edit_behaviours" onchange="editBehaviour(this, {$oField->getId()});"> | ||
| 88 | + <option>Select a behaviour</option> | ||
| 89 | + <!-- | ||
| 90 | + <option value="1">Behaviour 1</option> | ||
| 91 | + <option value="2">Behaviour 2</option> | ||
| 92 | + <option value="3">Behaviour 3</option> | ||
| 93 | + <option value="4">Behaviour 4</option> | ||
| 94 | + --> | ||
| 95 | + </select> | ||
| 96 | + <br /> | ||
| 97 | + <a href="#" onclick="changeAssignments({$oField->getId()}); return false;">Change Assignments for this field.</a> | ||
| 98 | + </div> | ||
| 99 | + </td> | ||
| 100 | +{/foreach} | ||
| 101 | +</tr> | ||
| 102 | +</tbody> | ||
| 103 | +</table> | ||
| 104 | + | ||
| 105 | + | ||
| 106 | +<!-- | ||
| 107 | +<table id="brad-log"> | ||
| 108 | +<tr> | ||
| 109 | + <th>Severity</th> | ||
| 110 | + <th>Time</th> | ||
| 111 | + <th>Entry</th> | ||
| 112 | +</tr> | ||
| 113 | +<tbody > | ||
| 114 | + | ||
| 115 | +</tbody> | ||
| 116 | +</table> | ||
| 117 | + | ||
| 118 | +--> | ||
| 0 | \ No newline at end of file | 119 | \ No newline at end of file |