Skip to content

Commit ce1866e

Browse files
committed
Latest working version
* Added optionData attribute for defining a variable on parent scope to act as the titleMap source for select * Reformatted main decorator file to follow https://github.com/johnpapa/angular-styleguide * General clean up * Converted some bindings to one-way, can review if this was needed later, but expect that the builder will refresh the content if it changes anyway
1 parent e371a17 commit ce1866e

20 files changed

+528
-434
lines changed

examples/data/sink.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,9 @@
187187
},
188188
"soul",
189189
{
190-
"type": "conditional",
191190
"condition": "modelData.soul",
192-
"items": [
193-
{
194-
"key": "soulserial",
195-
"placeholder": "ex. 666"
196-
}
197-
]
191+
"key": "soulserial",
192+
"placeholder": "ex. 666"
198193
},
199194
{
200195
"key": "date",

examples/data/titlemaps.json

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"type": "string",
1717
"enum": ["a","b","c"]
1818
},
19-
"noenum": { "type": "string", "title": "No enum, but forms says it's a select" },
19+
"noenum": { "type": "string", "title": "No enum, but forms says it's a select", "default": "a3" },
20+
"selectOptionData": { "type": "string", "title": "Dynamic Options", "default": "The Terminator" },
2021
"array": {
2122
"title": "Array with enum defaults to 'checkboxes'",
2223
"type": "array",
@@ -47,26 +48,40 @@
4748
}
4849
},
4950
"form": [
50-
"select",
5151
{
52-
"key": "select2",
53-
"type": "select",
54-
"titleMap": {
55-
"a": "A",
56-
"b": "B",
57-
"c": "C"
58-
}
59-
},
60-
{
61-
"key": "noenum",
62-
"type": "select",
63-
"titleMap": [
64-
{ "value":"a1", "name": "A1", "group": "A" },
65-
{ "value":"a2", "name":"A2", "group": "A" },
66-
{ "value":"a3", "name":"A3", "group": "A" },
67-
{ "value":"b1", "name": "B1", "group": "B" },
68-
{ "value":"b2", "name":"B2", "group": "B" },
69-
{ "value":"b3", "name":"B3", "group": "B" }
52+
"type": "section",
53+
"grid": {
54+
"flex": true,
55+
"layout": "row"
56+
},
57+
"items": [
58+
"select",
59+
{
60+
"key": "select2",
61+
"type": "select",
62+
"titleMap": {
63+
"a": "A",
64+
"b": "B",
65+
"c": "C"
66+
}
67+
},
68+
{
69+
"key": "noenum",
70+
"type": "select",
71+
"titleMap": [
72+
{ "value":"a1", "name": "A1", "group": "A" },
73+
{ "value":"a2", "name":"A2", "group": "A" },
74+
{ "value":"a3", "name":"A3", "group": "A" },
75+
{ "value":"b1", "name": "B1", "group": "B" },
76+
{ "value":"b2", "name":"B2", "group": "B" },
77+
{ "value":"b3", "name":"B3", "group": "B" }
78+
]
79+
},
80+
{
81+
"key": "selectOptionData",
82+
"type": "select",
83+
"optionData": "arnieFlix"
84+
}
7085
]
7186
},
7287
"array",

examples/img/icons/ic_clear_black_18px.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/material-example.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
<meta charset="utf-8">
55
<title>Material Design Schema Form Example</title>
66
<link rel="stylesheet" href="../bower_components/angular-material/angular-material.css">
7+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
78
<style type="text/css">
89
body,html {
910
min-height: 1400px;
11+
outline: none;
1012
}
1113

1214
.form { height: 400px; }
@@ -184,12 +186,12 @@ <h3>Schema</h3>
184186
app.controller('TestCtrl', function($scope, $http, $location, $timeout, $q) {
185187

186188
$scope.tests = [
187-
{ name: "Switch", data: 'data/switch.json'},
189+
{ name: "TitleMap Examples", data: 'data/titlemaps.json' },
188190
{ name: "Material Flex Grid", data: 'data/grid.json' },
189-
{ name: "Autocomplete", data: 'data/autocomplete.json' },
190191
{ name: "Simple", data: 'data/simple.json' },
191192
{ name: "Basic JSON Schema Type", data: 'data/types.json' },
192-
{ name: "TitleMap Examples", data: 'data/titlemaps.json' },
193+
{ name: "Autocomplete", data: 'data/autocomplete.json' },
194+
{ name: "Switch", data: 'data/switch.json'},
193195
/*{ name: "Complex Key Support", data: 'data/complex-keys.json' },*/
194196
/*{ name: "Array", data: 'data/array.json' },*/
195197
/*{ name: "Tab Array", data: 'data/tabarray.json' },*/

material-decorator.js

Lines changed: 211 additions & 146 deletions
Large diffs are not rendered by default.

material-decorator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/array.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<md-list class="list-group" sf-field-model ui-sortable="form.sortOptions">
66
<md-list-item layout="row" class="list-group-item"
77
sf-field-model="ng-repeat"
8-
ng-repeat="item in $$value$$ track by $index"
8+
ng-repeat="item in modelArray track by $index"
99
schema-form-array-items
1010
class="{{form.fieldHtmlClass}}">
1111
<md-button flex="none" flex-order="2"
@@ -15,7 +15,7 @@
1515
ng-disabled="form.schema.minItems >= modelArray.length"
1616
class="md-icon-button" aria-label="More"
1717
style="position: relative; z-index: 20;">
18-
<md-icon md-svg-icon="img/icons/ic_clear_black_18px.svg"></md-icon>
18+
<md-icon>close</md-icon>
1919
</md-button>
2020
</md-list-item>
2121
</md-list>

src/autocomplete.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="form-group {{form.htmlClass}} schema-form-select"
2-
ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false}">
3-
<md-autocomplete flex
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false}"
3+
sf-messages sf-layout>
4+
<md-autocomplete
45
ng-disabled="form.readonly"
56
ng-model="$$value$$"
67
sf-autocomplete
@@ -11,20 +12,13 @@
1112
md-selected-item-change="'todo';"
1213
md-items="item in evalExpr('this[\''+form.optionFilter+'\'](\''+searchText+'\')')"
1314
md-item-text="item.name"
14-
md-floating-label="{{form.title || form.key.slice(-1)[0]}}"
15+
md-floating-label="{{::form.title}}"
1516
md-menu-class="autocomplete-custom-template">
1617
<md-item-template>
17-
<span md-highlight-text="searchText">{{item.title}}</span>
18+
<span md-highlight-text="searchText">{{item.name}}</span>
1819
</md-item-template>
1920
<md-not-found>
2021
No matches found
2122
</md-not-found>
2223
</md-autocomplete>
23-
<div ng-messages="ngModel.$error">
24-
<!--
25-
This is a bit of a hack. sf-message does the work, but ng-messages and ng-message
26-
is needed for the styling
27-
-->
28-
<div sf-message ng-message></div>
29-
</div>
3024
</div>

src/checkbox.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
<div class="checkbox schema-form-checkbox {{form.htmlClass}}"
2-
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="checkbox schema-form-checkbox {{::form.htmlClass}}"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}"
3+
sf-messages>
34
<md-checkbox sf-field-model
45
sf-changed="form"
56
ng-disabled="form.readonly"
67
schema-validate="form"
7-
class="{{form.fieldHtmlClass}}"
8-
name="{{form.key.slice(-1)[0]}}"
9-
aria-label="{{form.title || form.key.slice(-1)[0]}}">
10-
<span ng-bind-html="form.title"></span>
8+
class="{{::form.fieldHtmlClass}}"
9+
name="{{::form.key|sfCamelKey}}"
10+
aria-label="{{::form.title}}">
11+
<span>{{::form.title}}</span>
1112
</md-checkbox>
12-
<div ng-messages="ngModel.$error">
13-
<!--
14-
This is a bit of a hack. sf-message does the work, but ng-messages and ng-message
15-
is needed for the styling
16-
-->
17-
<div sf-message ng-message></div>
18-
</div>
1913
</div>

src/checkboxes.html

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
<div sf-array="form" sf-field-model
2-
class="form-group schema-form-checkboxes {{form.htmlClass}}"
3-
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
4-
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
2+
class="form-group schema-form-checkboxes {{::form.htmlClass}}"
3+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}"
4+
sf-messages>
5+
<label class="control-label" ng-show="showTitle()">{{::form.title}}</label>
56
<div class="checkbox" ng-repeat="val in titleMapValues track by $index" >
67
<md-checkbox ng-model="titleMapValues[$index]"
7-
sf-changed="form"
8-
ng-disabled="form.readonly"
9-
name="{{form.key.slice(-1)[0]}}"
10-
ng-true-value="true"
11-
ng-false-value="false"
12-
aria-label="{{form.title || form.key.slice(-1)[0]}}">
13-
<span ng-bind-html="form.titleMap[$index].name"></span>
8+
sf-changed="form"
9+
ng-disabled="::form.readonly"
10+
name="{{::form.key|sfCamelKey}}"
11+
ng-true-value="true"
12+
ng-false-value="false"
13+
aria-label="{{::form.title}}">
14+
{{::form.titleMap[$index].name}}
1415
</md-checkbox>
1516
</div>
16-
<div ng-messages="ngModel.$error">
17-
<!--
18-
This is a bit of a hack. sf-message does the work, but ng-messages and ng-message
19-
is needed for the styling
20-
-->
21-
<div sf-message ng-message></div>
22-
</div>
2317
</div>

0 commit comments

Comments
 (0)