Commit 6d397502b92af81ae67a678d2ece2b2efb514d9f
1 parent
b5613f00
Split lookup values into enabled and disabled, and allow the ability to
set lookup values as disabled and enabled, and also set that this status is stuck in terms of automated synchronisation. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4006 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
120 additions
and
18 deletions
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/documentFields.php
| @@ -185,9 +185,23 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { | @@ -185,9 +185,23 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { | ||
| 185 | } | 185 | } |
| 186 | // }}} | 186 | // }}} |
| 187 | 187 | ||
| 188 | - // {{{ do_removeLookups | ||
| 189 | - function do_removeLookups() { | ||
| 190 | - $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); | 188 | + // {{{ do_metadataMultiAction |
| 189 | + function do_metadataMultiAction() { | ||
| 190 | + $subaction = array_keys(KTUtil::arrayGet($_REQUEST, 'submit', array())); | ||
| 191 | + $this->oValidator->notEmpty($subaction, array("message" => "No action specified")); | ||
| 192 | + $subaction = $subaction[0]; | ||
| 193 | + $method = null; | ||
| 194 | + if (method_exists($this, 'lookup_' . $subaction)) { | ||
| 195 | + $method = 'lookup_' . $subaction; | ||
| 196 | + } | ||
| 197 | + $this->oValidator->notEmpty($method, array("message" => "Unknown action specified")); | ||
| 198 | + return $this->$method(); | ||
| 199 | + } | ||
| 200 | + // }}} | ||
| 201 | + | ||
| 202 | + // {{{ lookup_remove | ||
| 203 | + function lookup_remove() { | ||
| 204 | + $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fFieldsetId']); | ||
| 191 | $oField =& DocumentField::get($_REQUEST['fFieldId']); | 205 | $oField =& DocumentField::get($_REQUEST['fFieldId']); |
| 192 | $aMetadata = KTUtil::arrayGet($_REQUEST, 'metadata'); | 206 | $aMetadata = KTUtil::arrayGet($_REQUEST, 'metadata'); |
| 193 | if (empty($aMetadata)) { | 207 | if (empty($aMetadata)) { |
| @@ -202,6 +216,61 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { | @@ -202,6 +216,61 @@ class KTDocumentFieldDispatcher extends KTStandardDispatcher { | ||
| 202 | } | 216 | } |
| 203 | // }}} | 217 | // }}} |
| 204 | 218 | ||
| 219 | + // {{{ lookup_disable | ||
| 220 | + function lookup_disable() { | ||
| 221 | + $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fFieldsetId']); | ||
| 222 | + $oField =& DocumentField::get($_REQUEST['fFieldId']); | ||
| 223 | + $aMetadata = KTUtil::arrayGet($_REQUEST, 'metadata'); | ||
| 224 | + if (empty($aMetadata)) { | ||
| 225 | + $this->errorRedirectTo('editField', 'No lookups selected', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 226 | + } | ||
| 227 | + foreach ($_REQUEST['metadata'] as $iMetaDataId) { | ||
| 228 | + $oMetaData =& MetaData::get($iMetaDataId); | ||
| 229 | + $oMetaData->setDisabled(true); | ||
| 230 | + $oMetaData->update(); | ||
| 231 | + } | ||
| 232 | + $this->successRedirectTo('editField', 'Lookups disabled', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 233 | + exit(0); | ||
| 234 | + } | ||
| 235 | + // }}} | ||
| 236 | + | ||
| 237 | + // {{{ lookup_enable | ||
| 238 | + function lookup_enable() { | ||
| 239 | + $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fFieldsetId']); | ||
| 240 | + $oField =& DocumentField::get($_REQUEST['fFieldId']); | ||
| 241 | + $aMetadata = KTUtil::arrayGet($_REQUEST, 'metadata'); | ||
| 242 | + if (empty($aMetadata)) { | ||
| 243 | + $this->errorRedirectTo('editField', 'No lookups selected', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 244 | + } | ||
| 245 | + foreach ($_REQUEST['metadata'] as $iMetaDataId) { | ||
| 246 | + $oMetaData =& MetaData::get($iMetaDataId); | ||
| 247 | + $oMetaData->setDisabled(false); | ||
| 248 | + $oMetaData->update(); | ||
| 249 | + } | ||
| 250 | + $this->successRedirectTo('editField', 'Lookups enabled', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 251 | + exit(0); | ||
| 252 | + } | ||
| 253 | + // }}} | ||
| 254 | + | ||
| 255 | + // {{{ lookup_togglestickiness | ||
| 256 | + function lookup_togglestickiness() { | ||
| 257 | + $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fFieldsetId']); | ||
| 258 | + $oField =& DocumentField::get($_REQUEST['fFieldId']); | ||
| 259 | + $aMetadata = KTUtil::arrayGet($_REQUEST, 'metadata'); | ||
| 260 | + if (empty($aMetadata)) { | ||
| 261 | + $this->errorRedirectTo('editField', 'No lookups selected', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 262 | + } | ||
| 263 | + foreach ($_REQUEST['metadata'] as $iMetaDataId) { | ||
| 264 | + $oMetaData =& MetaData::get($iMetaDataId); | ||
| 265 | + $bStuck = (boolean)$oMetaData->getIsStuck(); | ||
| 266 | + $oMetaData->setIsStuck(!$bStuck); | ||
| 267 | + $oMetaData->update(); | ||
| 268 | + } | ||
| 269 | + $this->successRedirectTo('editField', 'Lookup stickiness toggled', 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ||
| 270 | + exit(0); | ||
| 271 | + } | ||
| 272 | + // }}} | ||
| 273 | + | ||
| 205 | // {{{ do_becomeconditional | 274 | // {{{ do_becomeconditional |
| 206 | function do_becomeconditional() { | 275 | function do_becomeconditional() { |
| 207 | $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); | 276 | $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); |
templates/ktcore/metadata/editField.smarty
| @@ -19,38 +19,71 @@ | @@ -19,38 +19,71 @@ | ||
| 19 | </form> | 19 | </form> |
| 20 | 20 | ||
| 21 | {if $oField->getHasLookup()} | 21 | {if $oField->getHasLookup()} |
| 22 | -{assign var="aMetadata" value=$oField->getValues()} | ||
| 23 | -{if $aMetadata} | 22 | +{assign var="aEnabledMetadata" value=$oField->getEnabledValues()} |
| 23 | +{assign var="aDisabledMetadata" value=$oField->getDisabledValues()} | ||
| 24 | 24 | ||
| 25 | <h2>Lookup Values</h2> | 25 | <h2>Lookup Values</h2> |
| 26 | 26 | ||
| 27 | +<h3>Add new values</h3> | ||
| 28 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | ||
| 29 | +<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | ||
| 30 | +<input type="hidden" name="fFieldId" value="{$oField->getId()}"> | ||
| 31 | +<input type="hidden" name="action" value="addLookups"> | ||
| 32 | +<input type="textbox" name="value"> | ||
| 33 | +<input type="submit" name="submit" value="Add"> | ||
| 34 | +</form> | ||
| 35 | + | ||
| 36 | +{if $oField->getHasLookup() and $oField->getHasLookupTree()} | ||
| 37 | +{assign var=iFieldId value=$oField->getId()} | ||
| 38 | +<a | ||
| 39 | +href="{"manageLookupTrees"|generateControllerUrl:"action=editTree&field_id=$iFieldId"}">Manage | ||
| 40 | +lookup tree</a> | ||
| 41 | +{/if} | ||
| 42 | + | ||
| 43 | +{if $aEnabledMetadata} | ||
| 27 | <h3>Existing values</h3> | 44 | <h3>Existing values</h3> |
| 45 | + | ||
| 28 | <form action="{$smarty.server.PHP_SELF}" method="POST"> | 46 | <form action="{$smarty.server.PHP_SELF}" method="POST"> |
| 29 | <input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | 47 | <input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> |
| 30 | <input type="hidden" name="fFieldId" value="{$oField->getId()}"> | 48 | <input type="hidden" name="fFieldId" value="{$oField->getId()}"> |
| 31 | -<input type="hidden" name="action" value="removeLookups"> | 49 | +<input type="hidden" name="action" value="metadataMultiAction"> |
| 32 | <ul> | 50 | <ul> |
| 33 | -{foreach from=$aMetadata item=oMetaData} | ||
| 34 | - <li><label><input type="checkbox" name="metadata[]" value="{$oMetaData->getId()}">{$oMetaData->getName()|escape}</label> | 51 | +{foreach from=$aEnabledMetadata item=oMetaData} |
| 52 | + <li><label><input type="checkbox" name="metadata[]" | ||
| 53 | +value="{$oMetaData->getId()}">{$oMetaData->getName()|escape} | ||
| 54 | +{ if $oMetaData->getIsStuck() } | ||
| 55 | +<span class="helpText">(stuck, will never be disabled when synchronising | ||
| 56 | +from another source)</span> | ||
| 57 | +{ /if }</label> | ||
| 35 | {/foreach} | 58 | {/foreach} |
| 36 | </ul> | 59 | </ul> |
| 37 | -<input type="submit" name="submit" value="Remove"> | 60 | +<input type="submit" name="submit[disable]" value="Disable"> |
| 61 | +<input type="submit" name="submit[togglestickiness]" value="Toggle stickiness"> | ||
| 62 | +<input type="submit" name="submit[remove]" value="Remove"> | ||
| 38 | </form> | 63 | </form> |
| 39 | {/if} | 64 | {/if} |
| 40 | 65 | ||
| 41 | -<h3>Add new values</h3> | 66 | +{if $aDisabledMetadata} |
| 67 | +<h3>Disabled values</h3> | ||
| 68 | + | ||
| 42 | <form action="{$smarty.server.PHP_SELF}" method="POST"> | 69 | <form action="{$smarty.server.PHP_SELF}" method="POST"> |
| 43 | <input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> | 70 | <input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}"> |
| 44 | <input type="hidden" name="fFieldId" value="{$oField->getId()}"> | 71 | <input type="hidden" name="fFieldId" value="{$oField->getId()}"> |
| 45 | -<input type="hidden" name="action" value="addLookups"> | ||
| 46 | -<input type="textbox" name="value"> | ||
| 47 | -<input type="submit" name="submit" value="Add"> | 72 | +<input type="hidden" name="action" value="metadataMultiAction"> |
| 73 | +<ul> | ||
| 74 | +{foreach from=$aDisabledMetadata item=oMetaData} | ||
| 75 | + <li><label><input type="checkbox" name="metadata[]" | ||
| 76 | +value="{$oMetaData->getId()}">{$oMetaData->getName()|escape} | ||
| 77 | +{ if $oMetaData->getIsStuck() } | ||
| 78 | +<span class="helpText">(stuck, will never be enabled when synchronising | ||
| 79 | +from another source)</span> | ||
| 80 | +{ /if }</label> | ||
| 81 | +{/foreach} | ||
| 82 | +</ul> | ||
| 83 | +<input type="submit" name="submit[enable]" value="Enable"> | ||
| 84 | +<input type="submit" name="submit[togglestickiness]" value="Toggle stickiness"> | ||
| 85 | +<input type="submit" name="submit[remove]" value="Remove"> | ||
| 48 | </form> | 86 | </form> |
| 49 | {/if} | 87 | {/if} |
| 50 | 88 | ||
| 51 | -{if $oField->getHasLookup() and $oField->getHasLookupTree()} | ||
| 52 | -{assign var=iFieldId value=$oField->getId()} | ||
| 53 | -<a | ||
| 54 | -href="{"manageLookupTrees"|generateControllerUrl:"action=editTree&field_id=$iFieldId"}">Manage | ||
| 55 | -lookup tree</a> | ||
| 56 | {/if} | 89 | {/if} |