Permalink
Browse files

Merge pull request #24 from Phunkafizer/master

Channel properties on webinterface
  • Loading branch information...
2 parents 02c1ea5 + 966ce43 commit 735f82c8b7169f5bfa1c47bde70234bfaa4ef0b9 @justinotherguy justinotherguy committed Feb 13, 2012
Showing with 51 additions and 5 deletions.
  1. +0 −5 htdocs/frontend/index.html
  2. +51 −0 htdocs/frontend/javascripts/wui.js
@@ -161,11 +161,6 @@ <h2 id="title"></h2>
<tr class="property"><th>Eigenschaft</th><th>Wert</th></tr>
<tr class="property"><td>Middleware:</td><td><input type="text" id="entity-create-middleware" /></td></tr>
<tr class="property"><td>Typ:</td><td><select class="icons" name="type" size="1"></select></td></tr>
- <tr class="property"><td>&Ouml;ffentlich:</td><td><input type="radio" name="public" value="1"> ja&nbsp;&nbsp;<input type="radio" name="public" value="0"> nein</td></tr>
- <tr class="property"><td>Titel:</td><td><input type="text" name="title" value="Kühlschrank" /></td></tr>
- <tr class="property"><td>Aufl&ouml;sung:</td><td><input type="text" name="resolution" value="1000" /></td></tr>
- <tr class="property"><td>Kosten:<br /><p style="font-size: small">pro Wh</p></td><td><input type="text" name="cost" value="0.00025" /> €</td></tr>
- <tr class="property"><td>Beschreibung:</td><td><input type="text" name="description" value="Swissnox 1-phasig" /></td></tr>
</table>
<p><input type="submit" value="Erstellen" /> <label for="entity-create-cookie">Cookie:</label> <input id="entity-create-cookie" type="checkbox" /></p>
</form>
@@ -194,6 +194,57 @@ vz.wui.dialogs.init = function() {
$('#entity-add').dialog('close');
}
});
+
+ //Show available properties for selected type
+ function AddProperties(proplist, className) {
+ proplist.each(function(index, def) {
+ vz.capabilities.definitions.properties.each(function(propindex, propdef) {
+ if (def == propdef.name)
+ {
+ var row = $('<tr>').append($('<td>').text(propdef.translation[vz.options.language])).addClass("property");
+ var cntrl = null;
+
+ if ((propdef.type == 'string') || (propdef.type == 'text'))
+ cntrl = $('<input>').attr("type", "text");
+
+ if ((propdef.type == 'float') || (propdef.type == 'integer'))
+ cntrl = $('<input>').attr("type", "text");
+
+ if ((propdef.type == 'boolean'))
+ cntrl = $('<input>').attr("type", "checkbox");
+
+ if ((propdef.type == 'multiple'))
+ {
+ cntrl = $('<select>').attr("Size", "1");
+ propdef.options.each(function(optindex, optdef) {
+ cntrl.append(
+ $('<option>').html(optdef)
+ );
+ });
+ }
+
+ if (cntrl != null)
+ {
+ row.addClass(className);
+ cntrl.attr("name", propdef.name);
+ row.append($('<td>').append(cntrl));
+ $('#entity-create form table').append(row);
+ }
+ }
+ });
+ });
+ }
+
+ $('#entity-create select').change(function() {
+ $('#entity-create form table .required').remove();
+ $('#entity-create form table .optional').remove();
+
+ AddProperties(vz.capabilities.definitions.entities[$(this)[0].selectedIndex].required, "required");
+ AddProperties(vz.capabilities.definitions.entities[$(this)[0].selectedIndex].optional, "optional");
+ });
+
+ $('#entity-create select').change();
+
$('#entity-create form').submit(function() {
var def = $('select[name=type] option:selected', this).data('definition');

0 comments on commit 735f82c

Please sign in to comment.