Commit 92c893625b5d3851d952d94b2f1d6b4b7689a60a

Authored by bshuttle
1 parent 81251662

added templates and requisite SQL changes for the metadata changes.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3637 c91229c3-7414-0410-bfa2-8a42b809f60b
sql/mysql/install/data.sql
... ... @@ -81,7 +81,7 @@ INSERT INTO data_types VALUES (5, 'FLOAT');
81 81 -- Dumping data for table `document_fields`
82 82 --
83 83  
84   -INSERT INTO document_fields VALUES (1, 'Category', 'STRING', 1, NULL);
  84 +INSERT INTO document_fields VALUES (1, 'Category', 'STRING', 1, NULL, NULL);
85 85  
86 86 --
87 87 -- Dumping data for table `document_fields_link`
... ...
sql/mysql/install/structure.sql
... ... @@ -184,6 +184,25 @@ CREATE TABLE document_fields (
184 184 data_type char(100) NOT NULL default '',
185 185 is_generic tinyint(1) default NULL,
186 186 has_lookup tinyint(1) default NULL,
  187 + has_lookuptree tinyint(1) default NULL,
  188 + parent_fieldset int(11) default NULL,
  189 + UNIQUE KEY id (id)
  190 +) TYPE=InnoDB;
  191 +
  192 +-- --------------------------------------------------------
  193 +
  194 +
  195 +--
  196 +-- Table structure for table `document_fieldsets`
  197 +--
  198 +
  199 +CREATE TABLE document_fieldsets (
  200 + id int(11) NOT NULL default '0',
  201 + name char(255) NOT NULL default '',
  202 + namespace char(255) NOT NULL default '',
  203 + mandatory tinyint(4) NOT NULL default '0',
  204 + is_conditional tinyint(1) NOT NULL default '0', -- is this a conditional set?
  205 + master_field int(11) default NULL, -- if this is a conditional set, what is the MASTER FIELD.
187 206 UNIQUE KEY id (id)
188 207 ) TYPE=InnoDB;
189 208  
... ... @@ -309,6 +328,8 @@ CREATE TABLE document_transactions (
309 328 -- Table structure for table `document_type_fields_link`
310 329 --
311 330  
  331 +-- FIXME: we need to deprecate this.
  332 +
312 333 CREATE TABLE document_type_fields_link (
313 334 id int(11) NOT NULL default '0',
314 335 document_type_id int(11) NOT NULL default '0',
... ... @@ -320,6 +341,20 @@ CREATE TABLE document_type_fields_link (
320 341 -- --------------------------------------------------------
321 342  
322 343 --
  344 +-- Table structure for table `document_type_fieldsets_link`
  345 +--
  346 +
  347 +CREATE TABLE document_type_fieldsets_link (
  348 + id int(11) NOT NULL default '0',
  349 + document_type_id int(11) NOT NULL default '0',
  350 + fieldset_id int(11) NOT NULL default '0',
  351 + is_mandatory tinyint(1) NOT NULL default '0',
  352 + UNIQUE KEY id (id)
  353 +) TYPE=InnoDB;
  354 +
  355 +-- --------------------------------------------------------
  356 +
  357 +--
323 358 -- Table structure for table `document_types_lookup`
324 359 --
325 360  
... ... @@ -360,7 +395,7 @@ CREATE TABLE documents (
360 395 permission_lookup_id int(11) default NULL,
361 396 live_document_id int(11) default NULL,
362 397 metadata_version int(11) NOT NULL default '0',
363   - storage_path varchar(250) default NULL,
  398 + storage_path varchar(250) default NULL,
364 399 UNIQUE KEY id (id),
365 400 KEY fk_document_type_id (document_type_id),
366 401 KEY fk_creator_id (creator_id),
... ... @@ -573,6 +608,42 @@ CREATE TABLE metadata_lookup (
573 608 id int(11) NOT NULL default '0',
574 609 document_field_id int(11) NOT NULL default '0',
575 610 name char(255) default NULL,
  611 + treeorg_parent int(11) default NULL,
  612 + UNIQUE KEY id (id)
  613 +) TYPE=InnoDB;
  614 +
  615 +
  616 +--
  617 +-- Table structure for table `metadata_lookup_tree`
  618 +--
  619 +
  620 +CREATE TABLE metadata_lookup_tree (
  621 + id int(11) NOT NULL default '0',
  622 + document_field_id int(11) NOT NULL default '0',
  623 + name char(255) default NULL,
  624 + metadata_lookup_tree_parent int(11) default NULL, -- parent id of the parent within this tree. NULL indicates attachment to root.
  625 + UNIQUE KEY id (id),
  626 + INDEX (metadata_lookup_tree_parent),
  627 + INDEX (document_field_id)
  628 +) TYPE=InnoDB;
  629 +
  630 +--
  631 +-- Table structure for table `metadata_lookup_tree`
  632 +--
  633 +
  634 +CREATE TABLE metadata_lookup_condition (
  635 + id int(11) NOT NULL default '0',
  636 + document_field_id int(11) NOT NULL default '0',
  637 + metadata_lookup_id int(11) NOT NULL default '0', -- probably inherently broken if its NULL.
  638 + name char(255) default NULL, -- allows us to give human-names to various different subrules, and also check for non-trivial rules.
  639 + UNIQUE KEY id (id)
  640 +) TYPE=InnoDB;
  641 +
  642 +
  643 +CREATE TABLE metadata_lookup_condition_chain (
  644 + id int(11) NOT NULL default '0',
  645 + parent_condition int(11) default NULL, -- null indicates "no parent".
  646 + child_condition int(11) NOT NULL default '0',
576 647 UNIQUE KEY id (id)
577 648 ) TYPE=InnoDB;
578 649  
... ... @@ -1059,6 +1130,19 @@ CREATE TABLE zseq_document_fields (
1059 1130 PRIMARY KEY (id)
1060 1131 ) TYPE=MyISAM;
1061 1132  
  1133 +
  1134 +-- --------------------------------------------------------
  1135 +
  1136 +--
  1137 +-- Table structure for table `zseq_document_fields`
  1138 +--
  1139 +
  1140 +CREATE TABLE zseq_document_fieldsets (
  1141 + id int(10) unsigned NOT NULL auto_increment,
  1142 + PRIMARY KEY (id)
  1143 +) TYPE=InnoDB;
  1144 +
  1145 +
1062 1146 -- --------------------------------------------------------
1063 1147  
1064 1148 --
... ... @@ -1301,6 +1385,26 @@ CREATE TABLE zseq_metadata_lookup (
1301 1385 PRIMARY KEY (id)
1302 1386 ) TYPE=MyISAM;
1303 1387  
  1388 +--
  1389 +-- Table structure for table `zseq_metadata_lookup`
  1390 +--
  1391 +
  1392 +CREATE TABLE zseq_metadata_lookup_tree (
  1393 + id int(10) unsigned NOT NULL auto_increment,
  1394 + PRIMARY KEY (id)
  1395 +) TYPE=InnoDB;
  1396 +
  1397 +CREATE TABLE zseq_metadata_lookup_condition (
  1398 + id int(10) unsigned NOT NULL auto_increment,
  1399 + PRIMARY KEY (id)
  1400 +) TYPE=InnoDB;
  1401 +
  1402 +CREATE TABLE zseq_metadata_lookup_condition_chain (
  1403 + id int(10) unsigned NOT NULL auto_increment,
  1404 + PRIMARY KEY (id)
  1405 +) TYPE=InnoDB;
  1406 +
  1407 +
1304 1408 -- --------------------------------------------------------
1305 1409  
1306 1410 --
... ...
templates/ktcore/edit_conditional.smarty 0 → 100644
  1 +<h2>Edit Fieldset</h2>
  2 +
  3 +<form>
  4 +<fieldset>
  5 +<legend>Current Fields in Set</legend>
  6 +<p>Fields which are currently not included in any set can be added to this set.</p>
  7 +
  8 +<input type="hidden" name="id" value="{$setId}" />
  9 +<input type="hidden" name="action" value="removeFromFieldset" />
  10 +{if (empty($children))}
  11 +<p>No fields associated with this fieldset.</p>
  12 +{else}
  13 +{foreach item=oField from=$children}
  14 + <input type="checkbox" name="fieldsToRemove[]" value="{$oField->getId()}">{$oField->getName()}</input>
  15 +{/foreach}
  16 +{/if}
  17 +<div>
  18 +<input type="submit" name="submit" value="Remove">
  19 +</div>
  20 +</fieldset>
  21 +</form>
  22 +
  23 +
  24 +
  25 +<fieldset>
  26 +<legend>Add Field to set</legend>
  27 +<p>Fields which are currently not included in any set can be added to this set.</p>
  28 +<form>
  29 +<input type="hidden" name="id" value="{$setId}" />
  30 +<input type="hidden" name="action" value="addToFieldset">
  31 +
  32 +{if (empty($freefields))}
  33 +<p>No free fields.</p>
  34 +{else}
  35 +<select name="fieldsToAdd[]" multiple="true">
  36 +{foreach item=oField from=$freefields}
  37 + <option value="{$oField->getId()}">{$oField->getName()}</option>
  38 +{/foreach}
  39 +</select>
  40 +{/if}
  41 +<div>
  42 +<input type="submit" name="submit" value="Add to Fieldset">
  43 +</div>
  44 +</form>
  45 +</fieldset>
  46 +
  47 +
  48 +{if ($fieldSet->canBeMadeConditional() === true)}
  49 +<fieldset>
  50 +<legend>Make this fieldset conditional</legend>
  51 +
  52 +<form>
  53 +<input type="hidden" name="id" value="{$setId}" />
  54 +<input type="hidden" name="action" value="makeConditionalSet">
  55 +
  56 +{if (empty($freefields))}
  57 +<p>No free fields.</p>
  58 +{else}
  59 +<select name="fieldsToAdd" multiple="true">
  60 +{foreach item=oField from=$freefields}
  61 + <option value="{$oField->getId()}">{$oField->getName()}</option>
  62 +{/foreach}
  63 +</select>
  64 +{/if}
  65 +<div>
  66 +<input type="submit" name="submit" value="Add to Fieldset">
  67 +</div>
  68 +</form>
  69 +</fieldset>
  70 +
  71 +{else}
  72 +{if ($fieldSet->getIsConditional())}
  73 +Field has conditions attached to it..
  74 +<ul>
  75 + <li>Manage conditions.</li>
  76 + <li>Test conditions</li>
  77 +</ul>
  78 +{else}
  79 +<p>Fieldset cannot be made conditional. One of the fields must not be a lookup.</p>
  80 +{/if}
  81 +{/if}
... ...
templates/ktcore/edit_fieldset.smarty 0 → 100644
  1 +<h2>Edit Fieldset</h2>
  2 +
  3 +<form>
  4 +<fieldset>
  5 +<legend>Current Fields in Set</legend>
  6 +<p>Fields which are currently not included in any set can be added to this set.</p>
  7 +
  8 +<input type="hidden" name="id" value="{$setId}" />
  9 +<input type="hidden" name="action" value="removeFromFieldset" />
  10 +{if (empty($children))}
  11 +<p>No fields associated with this fieldset.</p>
  12 +{else}
  13 +{foreach item=oField from=$children}
  14 + <input type="checkbox" name="fieldsToRemove[]" value="{$oField->getId()}">{$oField->getName()}</input>
  15 +{/foreach}
  16 +{/if}
  17 +<div>
  18 +<input type="submit" name="submit" value="Remove">
  19 +</div>
  20 +</fieldset>
  21 +</form>
  22 +
  23 +
  24 +
  25 +<fieldset>
  26 +<legend>Add Field to set</legend>
  27 +<p>Fields which are currently not included in any set can be added to this set.</p>
  28 +<form>
  29 +<input type="hidden" name="id" value="{$setId}" />
  30 +<input type="hidden" name="action" value="addToFieldset">
  31 +
  32 +{if (empty($freefields))}
  33 +<p>No free fields.</p>
  34 +{else}
  35 +<select name="fieldsToAdd[]" multiple="true">
  36 +{foreach item=oField from=$freefields}
  37 + <option value="{$oField->getId()}">{$oField->getName()}</option>
  38 +{/foreach}
  39 +</select>
  40 +{/if}
  41 +<div>
  42 +<input type="submit" name="submit" value="Add to Fieldset">
  43 +</div>
  44 +</form>
  45 +</fieldset>
  46 +
  47 +
  48 +{if ($fieldSet->canBeMadeConditional() === true)}
  49 +<fieldset>
  50 +<legend>Make this fieldset conditional</legend>
  51 +
  52 +<form>
  53 +<input type="hidden" name="id" value="{$setId}" />
  54 +<input type="hidden" name="action" value="makeConditionalSet">
  55 +
  56 +{if (empty($freefields))}
  57 +<p>No free fields.</p>
  58 +{else}
  59 +<select name="fieldsToAdd" multiple="true">
  60 +{foreach item=oField from=$freefields}
  61 + <option value="{$oField->getId()}">{$oField->getName()}</option>
  62 +{/foreach}
  63 +</select>
  64 +{/if}
  65 +<div>
  66 +<input type="submit" name="submit" value="Add to Fieldset">
  67 +</div>
  68 +</form>
  69 +</fieldset>
  70 +
  71 +{else}
  72 +{if ($fieldSet->getIsConditional())}
  73 +Field has conditions attached to it..
  74 +<ul>
  75 + <li>Manage conditions.</li>
  76 + <li>Test conditions</li>
  77 +</ul>
  78 +{else}
  79 +<p>Fieldset cannot be made conditional. One of the fields must not be a lookup.</p>
  80 +{/if}
  81 +{/if}
... ...
templates/ktcore/edit_lookuptrees.smarty 0 → 100644
  1 +{literal}
  2 +<style>
  3 +
  4 +.kt_treenodes {
  5 + list-style: none;
  6 + margin: 0;
  7 + padding: 0;
  8 + border: 0;
  9 +}
  10 +
  11 +.leafnode {font-weight: bold; }
  12 +
  13 +.kt_treenodes ul {
  14 + list-style: none;
  15 +}
  16 +.kt_treenodes li.treenode > a.pathnode {
  17 + background: transparent url(/graphics/plus.png) center left no-repeat;
  18 + padding-left: 15px;
  19 +}
  20 +
  21 +.kt_treenodes li.treenode.active > a.pathnode {
  22 + background: transparent url(/graphics/minus.png) center left no-repeat;
  23 +}
  24 +
  25 +.kt_treenodes li.active > ul {
  26 + display: block;
  27 +}
  28 +
  29 +.kt_treenodes li ul {
  30 + display: none;
  31 +}
  32 +
  33 +</style>
  34 +{/literal}
  35 +
  36 +<script language="javascript" src="/thirdpartyjs/MochiKit/Base.js">
  37 +<script language="javascript" src="/thirdpartyjs/MochiKit/Iter.js">
  38 +<script language="javascript" src="/thirdpartyjs/MochiKit/DOM.js">
  39 +
  40 +<h1>Edit Lookup Tree: {$field->getName()}</h1>
  41 +
  42 +<fieldset>
  43 +<legend>Editing Category:
  44 +{if ($currentNode == 0)}
  45 +Root
  46 +{else}
  47 +{$tree->mapnodes[$currentNode]->getName()}
  48 +{/if}
  49 +</legend>
  50 +
  51 +<form>
  52 +<fieldset>
  53 + <legend>Add New Subcategory</legend>
  54 + <input type="hidden" name="field_id" value="{$field->getId()}" />
  55 + <input type="hidden" name="action" value="editTree" />
  56 + <input type="hidden" name="subaction" value="addCategory" />
  57 + <input type="hidden" name="current_node" value="{$currentNode}" />
  58 +
  59 +<input type="text" name="category_name"/>
  60 +
  61 +<div class="formControls">
  62 + <input type="submit" name="submit" value="Add Category" />
  63 +</div>
  64 +</fieldset>
  65 +</form>
  66 +{if ($currentNode != 0)}
  67 +{if (empty($freechildren))}
  68 +<p>No free keywords. Use the "unlink" action on a keyword to
  69 +make it available.</p>
  70 +{else}
  71 +<form>
  72 +<fieldset>
  73 + <legend>Link free keywords.</legend>
  74 + <input type="hidden" name="field_id" value="{$field->getId()}" />
  75 + <input type="hidden" name="action" value="editTree" />
  76 + <input type="hidden" name="subaction" value="linkKeywords" />
  77 + <input type="hidden" name="current_node" value="{$currentNode}" />
  78 +
  79 +
  80 +
  81 +<select multiple="1" name="keywordsToAdd[]">
  82 + {foreach item=oKeyword from=$freechildren}
  83 + <option value="{$oKeyword->getId()}">{$oKeyword->getName()}</option>
  84 + {/foreach}
  85 +</select>
  86 +
  87 +<div class="formControls">
  88 + <input type="submit" name="submit" value="Add Category" />
  89 +</div>
  90 +</fieldset>
  91 +</form>
  92 +{/if}
  93 +{/if}
  94 +</fieldset>
  95 +
  96 +
  97 +
  98 +<h2>Preview</h2>
  99 +<div class="helpText">
  100 + Use the +/- arrows to open or close the tree. Bold items are metadata keywords.
  101 + To edit a category (including adding or removing keywords) click on the "edit" link.
  102 +</div>
  103 +
  104 +{$renderedTree}
... ...
templates/ktcore/handle_conditional.smarty 0 → 100644
  1 +<html>
  2 +<head><title>Conditional Metadata Test</title>
  3 +</head>
  4 +<body>
  5 + <p>This is test of the various configurations for the conditional metadata backend. Please press submit. Your current form
  6 + will be deleted, and the backend will present new fields for you to fill in.</p>
  7 + <form>
  8 +
  9 +
  10 +
  11 + <input type="hidden" name="fieldset_id" value="{$fieldset}" />
  12 +
  13 + {foreach item=oldFieldVal key=oldFieldId from=$oldfields}
  14 + <input type="hidden" name="fields[]" value="{$oldFieldId}" />
  15 + <input type="hidden" name="conditional_field_{$oldFieldId}" value="{$oldFieldVal}" />
  16 + {/foreach}
  17 + {foreach item=fieldOutput key=field_id from=$fieldsToRender}
  18 + <input type="hidden" name="fields[]" value="{$field_id}" />
  19 + <select name="conditional_field_{$field_id}">
  20 + {foreach item=metadata from=$fieldOutput}
  21 + <option value="{$metadata.val}">{$metadata.name}</option>
  22 + {/foreach}
  23 + </select>
  24 + {/foreach}
  25 +
  26 +
  27 + <input type="submit" />
  28 + </form>
  29 +</body>
  30 +</html>
... ...
templates/ktcore/manage_fieldsets.smarty 0 → 100644
  1 +<h2>Existing Fieldsets</h2>
  2 +<table class="pretty" cellspacing="0" cellpadding="0" border="0">
  3 + <thead>
  4 + <tr>
  5 + <th>Human Name</th>
  6 + <th>Namespace</th>
  7 + <th colspan="2">Manage</th>
  8 + </tr>
  9 + </thead>
  10 + { foreach item=oFieldSet from=$fieldsets }
  11 + <tr class="{cycle values="odd,even"}">
  12 + <td>
  13 + { $oFieldSet->sName }
  14 + </td>
  15 + <td>
  16 + { $oFieldSet->sNamespace}
  17 + </td>
  18 +
  19 + <td>
  20 + <a
  21 + href="{$smarty.server.PHP_SELF}?action=editFieldset&id={$oFieldSet->getId()}">Edit</a>
  22 + </td>
  23 + <td>
  24 + {if $oFieldSet->bMandatory == false}
  25 + <a
  26 + href="{$smarty.server.PHP_SELF}?action=deleteFieldset&id={$oFieldSet->getId()}">Delete</a>
  27 + {else}
  28 + Built-in set.
  29 + {/if}
  30 + </td>
  31 +
  32 + </tr>
  33 + { /foreach }
  34 +</table>
  35 +
  36 +<h2>Create a new Fieldset</h2>
  37 +
  38 +<form>
  39 +<input type="hidden" name="action" value="newFieldset">
  40 +<table>
  41 +<tr>
  42 +<td>Name:</td>
  43 +<td><input type="text" name="name" value=""></td>
  44 +</tr>
  45 +<tr>
  46 +<td>Namespace:</td>
  47 +<td><input type="text" name="namespace" value="http://knowledgetree.jamwarehouse.com/fieldsets/custom/"></td>
  48 +</tr>
  49 +<tr>
  50 +<td colspan="2" align="right">
  51 +<input type="submit" name="submit" value="Create Fieldset">
  52 +</td>
  53 +</tr>
  54 +</table>
  55 +</form>
... ...
templates/ktcore/manage_lookuptrees.smarty 0 → 100644
  1 +<h1>Manage Lookup Trees</h1>
  2 +<form>
  3 +<fieldset>
  4 +<legend>Fields that have lookup categories.</legend>
  5 +
  6 +<input type="hidden" name="action" value="editTree" />
  7 +{foreach item=oField from=$treefields}
  8 + <input type="radio" name="field_id" value="{$oField->getId()}">{$oField->getName()}</input>
  9 +{/foreach}
  10 +<div class="formControls">
  11 +<input type="submit" name="submit" value="Edit Categorisation">
  12 +</div>
  13 +</fieldset>
  14 +</form>
  15 +
  16 +<h2>Convert to Trees.</h2>
  17 +<form>
  18 +<fieldset>
  19 +<legend>Lookup fields without categories.</legend>
  20 +
  21 +<input type="hidden" name="action" value="createTree" />
  22 +{foreach item=oField from=$lookupfields}
  23 + <input type="radio" name="field_id" value="{$oField->getId()}">{$oField->getName()}</input>
  24 +{/foreach}
  25 +<div class="formControls">
  26 +<input type="submit" name="submit" value="Convert">
  27 +</div>
  28 +</fieldset>
  29 +</form>
... ...
templates/ktcore/metadata_fields/editable_metadata_fields.smarty
  1 +{literal}
  2 +<style>
  3 +
  4 +.kt_treenodes {
  5 + list-style: none;
  6 + margin: 0;
  7 + padding: 0;
  8 + border: 0;
  9 + text-align: left !important;
  10 +}
  11 +
  12 +.leafnode {font-weight: bold; }
  13 +
  14 +.kt_treenodes ul {
  15 + list-style: none;
  16 + text-align: left;
  17 +}
  18 +.kt_treenodes li.treenode > a.pathnode {
  19 + background: transparent url(/graphics/plus.png) center left no-repeat;
  20 + padding-left: 15px;
  21 +}
  22 +
  23 +.kt_treenodes li.treenode.active > a.pathnode {
  24 + background: transparent url(/graphics/minus.png) center left no-repeat;
  25 +}
  26 +
  27 +.kt_treenodes li.active > ul {
  28 + display: block;
  29 +}
  30 +
  31 +.kt_treenodes li ul {
  32 + display: none;
  33 +}
  34 +
  35 +</style>
  36 +{/literal}
  37 +
  38 +<script language="javascript" src="/thirdpartyjs/MochiKit/Base.js" > </script>
  39 +<script language="javascript" src="/thirdpartyjs/MochiKit/Iter.js" > </script>
  40 +<script language="javascript" src="/thirdpartyjs/MochiKit/DOM.js" > </script>
  41 +
  42 +
1 43 <table class="prettysw" cellpadding="0" cellspacing="0">
2 44 {if !$metadata_prefix}
3 45 {assign var="metadata_prefix" value="emd"}
... ...