Skip to content

Commit

Permalink
Automatically show appropriate controls by channeltype when creating …
Browse files Browse the repository at this point in the history
…a channel
  • Loading branch information
unknown authored and unknown committed Feb 10, 2012
1 parent 02c1ea5 commit 966ce43
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
5 changes: 0 additions & 5 deletions htdocs/frontend/index.html
Expand Up @@ -161,11 +161,6 @@ <h3><img src="images/wrench.png" alt="" /> Optionen</h3>
<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>
Expand Down
51 changes: 51 additions & 0 deletions htdocs/frontend/javascripts/wui.js
Expand Up @@ -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');
Expand Down

0 comments on commit 966ce43

Please sign in to comment.