Skip to content

Commit

Permalink
Implement the checkbox control
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Apr 3, 2013
1 parent 971a9ac commit 2aa16cc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hawtio-web/src/main/webapp/app/forms/html/test.html
Expand Up @@ -8,7 +8,7 @@ <h3>Form Testing</h3>
<a class='btn' ng-href="" hawtio-reset='form-with-inline-arguments'><i class="icon-refresh"></i> Clear</a>
</div>
Form with inline arguments
<div simple-form name='form-with-inline-arguments' action='#/forms/test' method='post' data='setVMOption' entity='cheese' onSubmit="derp()" submitText="Derp"></div>
<div simple-form name='form-with-inline-arguments' action='#/forms/test' method='post' data='setVMOption' entity='cheese' onSubmit="derp()"></div>
</div>

<hr>
Expand All @@ -18,7 +18,7 @@ <h3>Form Testing</h3>
<div class="row-fluid">
<button class="btn" ng-click="toggleEdit()">Edit</button>
</div>
<div simple-form='config' entity='cheese' mode='view'></div>
<div simple-form data='setVMOption' entity='cheese' mode='view'></div>
</div>

<hr>
Expand Down
28 changes: 24 additions & 4 deletions hawtio-web/src/main/webapp/app/forms/js/baseDirectives.ts
Expand Up @@ -86,7 +86,7 @@ module Forms {

export class TextInput extends InputBase {

public type="text";
public type = "text";

constructor(private workspace, private $compile) {
super(workspace, $compile);
Expand Down Expand Up @@ -235,10 +235,30 @@ module Forms {
super(workspace, $compile);
}

private doLink(scope, element, attrs) {
// TODO
console.log("BooleanInput");
public getInput(config, arg, id) {

var rc = $('<input class="hawtio-checkbox" type="checkbox">');
rc.attr('name', id);

if (config.isReadOnly()) {
rc.attr('disabled', 'true');
}

var modelName = arg.model;
if (!angular.isDefined(arg.model)) {
// TODO always use 2 way binding?
modelName = config.getEntity() + "." + id;
}
if (modelName) {
rc.attr('ng-model', modelName);
}
if (config.isReadOnly()) {
rc.attr('readonly', 'true');
}
return rc;
}


}


Expand Down
3 changes: 3 additions & 0 deletions hawtio-web/src/main/webapp/app/forms/js/formPlugin.ts
Expand Up @@ -24,6 +24,9 @@ module Forms {
directive('hawtioFormObject', function(workspace, $compile) {
return new Forms.ObjectInput(workspace, $compile);
}).
directive('hawtioFormCheckbox', function(workspace, $compile) {
return new Forms.BooleanInput(workspace, $compile);
}).
directive('hawtioSubmit', function() {
return new Forms.SubmitForm();
}).
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/forms/js/mappingRegistry.ts
Expand Up @@ -24,6 +24,10 @@ module Forms {
case "object":
case "java.lang.object":
return "hawtio-form-object";
case "boolean":
case "bool":
case "java.lang.boolean":
return "hawtio-form-checkbox";
default:
// lets check if this name is an alias to a definition in the schema
return "hawtio-form-text";
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/forms/js/test.ts
Expand Up @@ -38,6 +38,10 @@ module Forms {
'objectArg': {
description: 'some object',
type: 'object'
},
'booleanArg': {
description: 'Some boolean value',
type: 'java.lang.Boolean'
}
// TODO - add more types, above is what I remember from jolokia
},
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/css/site-base.css
Expand Up @@ -897,3 +897,7 @@ div#main div div div div div.logbar div.logbar-container ul.nav.nav-tabs {
display: inline-block;
margin: 5px;
}

input[type="checkbox"].hawtio-checkbox {
margin-top: 10px;
}

0 comments on commit 2aa16cc

Please sign in to comment.