Skip to content

Commit 441c659

Browse files
committed
Minor updates to date + array
Fixes for action buttons Date picker style Added initial array list, needs work and styling still
1 parent e2489c0 commit 441c659

10 files changed

+90
-75
lines changed

examples/data/sink.json

+3-12
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,6 @@
173173
{
174174
"key": "shoesizeRight"
175175
},
176-
{
177-
"key": "invitation",
178-
"tinymceOptions": {
179-
"toolbar": [
180-
"undo redo| styleselect | bold italic | link image",
181-
"alignleft aligncenter alignright"
182-
]
183-
}
184-
},
185176
"things",
186177
"dislike"
187178
]
@@ -207,7 +198,7 @@
207198
},
208199
{
209200
"key": "date",
210-
"minDate": "2014-06-20"
201+
"minDate": "2015-06-20"
211202
},
212203
{
213204
"key": "radio",
@@ -251,12 +242,12 @@
251242
"items": [
252243
{
253244
"type": "submit",
254-
"style": "btn-info",
245+
"style": "md-primary",
255246
"title": "Do It!"
256247
},
257248
{
258249
"type": "button",
259-
"style": "btn-danger",
250+
"style": "md-warn",
260251
"title": "Noooooooooooo",
261252
"onClick": "sayNo()"
262253
}
Loading

examples/material-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ <h3>Schema</h3>
279279
app.controller('TestCtrl', function($scope, $http, $location, $timeout, $q) {
280280

281281
$scope.tests = [
282-
{ name: "Material Flex Grid", data: 'data/grid.json' },
283282
{ name: "Autocomplete", data: 'data/autocomplete.json' },
283+
{ name: "Material Flex Grid", data: 'data/grid.json' },
284284
{ name: "Simple", data: 'data/simple.json' },
285285
{ name: "Basic JSON Schema Type", data: 'data/types.json' },
286286
{ name: "TitleMap Examples", data: 'data/titlemaps.json' },

material-decorator.js

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("decorators/material/actions-trcl.html","<div class=\"btn-group schema-form-actions {{form.htmlClass}}\" ng-transclude=\"\"></div>");
2-
$templateCache.put("decorators/material/actions.html","<div class=\"btn-group schema-form-actions {{form.htmlClass}}\"><input ng-repeat-start=\"item in form.items\" type=\"submit\" class=\"btn {{ item.style || \'btn-default\' }} {{form.fieldHtmlClass}}\" value=\"{{item.title}}\" ng-if=\"item.type === \'submit\'\"> <button ng-repeat-end=\"\" class=\"btn {{ item.style || \'btn-default\' }} {{form.fieldHtmlClass}}\" type=\"button\" ng-disabled=\"form.readonly\" ng-if=\"item.type !== \'submit\'\" ng-click=\"buttonClick($event,item)\">{{item.title}}</button></div>");
3-
$templateCache.put("decorators/material/array.html","<div sf-array=\"form\" class=\"schema-form-array {{form.htmlClass}}\" ng-model=\"$$value$$\" ng-model-options=\"form.ngModelOptions\"><h3 ng-show=\"form.title && form.notitle !== true\">{{ form.title }}</h3><ol class=\"list-group\" ng-model=\"modelArray\" ui-sortable=\"\"><li class=\"list-group-item {{form.fieldHtmlClass}}\" ng-repeat=\"item in modelArray track by $index\"><md-button ng-hide=\"form.readonly || form.remove === null\" ng-click=\"deleteFromArray($index)\" style=\"position: relative; z-index: 20;\" type=\"button\" class=\"close pull-right\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></md-button><sf-decorator ng-init=\"arrayIndex = $index\" form=\"copyWithIndex($index)\"></sf-decorator></li></ol><div class=\"clearfix\" style=\"padding: 15px;\"><md-button ng-hide=\"form.readonly || form.add === null\" ng-click=\"appendToArray()\" type=\"button\" class=\"btn {{ form.style.add || \'btn-default\' }} pull-right\"><i class=\"glyphicon glyphicon-plus\"></i> {{ form.add || \'Add\'}}</md-button></div><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></div>");
2+
$templateCache.put("decorators/material/actions.html","<section layout=\"row\" class=\"btn-group schema-form-actions {{form.htmlClass}}\"></section>");
3+
$templateCache.put("decorators/material/array.html","<div class=\"schema-form-array {{form.htmlClass}}\" sf-field-model=\"sf-new-array\" sf-new-array=\"\"><label class=\"control-label\" ng-show=\"showTitle()\">{{ form.title }}</label><md-list class=\"list-group\" sf-field-model=\"\" ui-sortable=\"form.sortOptions\"><md-list-item layout=\"row\" class=\"list-group-item\" sf-field-model=\"ng-repeat\" ng-repeat=\"item in $$value$$ track by $index\" schema-form-array-items=\"\"><md-button flex=\"none\" flex-order=\"2\" type=\"button\" ng-hide=\"form.readonly || form.remove === null\" ng-click=\"deleteFromArray($index)\" ng-disabled=\"form.schema.minItems >= modelArray.length\" class=\"md-icon-button\" aria-label=\"More\" style=\"position: relative; z-index: 20;\"><md-icon md-svg-icon=\"img/icons/ic_clear_black_18px.svg\"></md-icon></md-button></md-list-item></md-list><div class=\"clearfix\" style=\"padding: 15px;\" ng-model=\"modelArray\" schema-validate=\"form\"><div class=\"help-block\" ng-show=\"(hasError() && errorMessage(schemaError())) || form.description\" ng-bind-html=\"(hasError() && errorMessage(schemaError())) || form.description\"></div><md-button ng-hide=\"form.readonly || form.add === null\" ng-click=\"appendToArray()\" ng-disabled=\"form.schema.maxItems <= modelArray.length\" type=\"button\" class=\"btn md-raised md-primary {{ form.style.add || \'btn-default\' }} pull-right\"><i class=\"glyphicon glyphicon-plus\"></i> {{ form.add || \'Add\'}}</md-button></div></div>");
44
$templateCache.put("decorators/material/autocomplete.html","<div class=\"form-group {{form.htmlClass}} schema-form-select\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\"><md-autocomplete flex=\"\" ng-disabled=\"form.readonly\" ng-model=\"$$value$$\" sf-autocomplete=\"\" sf-field-model=\"replaceAll\" schema-validate=\"form\" md-selected-item=\"$$value$$\" md-search-text=\"searchText\" md-selected-item-change=\"\'todo\';\" md-items=\"item in evalExpr(\'this[\\\'\'+form.optionFilter+\'\\\'](\\\'\'+searchText+\'\\\')\')\" md-item-text=\"item.name\" md-floating-label=\"{{form.title || form.key.slice(-1)[0]}}\" md-menu-class=\"autocomplete-custom-template\"><md-item-template><span md-highlight-text=\"searchText\">{{item.title}}</span></md-item-template><md-not-found>No matches found</md-not-found></md-autocomplete><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></div>");
55
$templateCache.put("decorators/material/checkbox.html","<div class=\"checkbox schema-form-checkbox {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\"><md-checkbox sf-field-model=\"\" sf-changed=\"form\" ng-disabled=\"form.readonly\" schema-validate=\"form\" class=\"{{form.fieldHtmlClass}}\" name=\"{{form.key.slice(-1)[0]}}\" aria-label=\"{{form.title || form.key.slice(-1)[0]}}\"><span ng-bind-html=\"form.title\"></span></md-checkbox><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></div>");
66
$templateCache.put("decorators/material/checkboxes.html","<div sf-array=\"form\" sf-field-model=\"\" class=\"form-group schema-form-checkboxes {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\"><label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label><div class=\"checkbox\" ng-repeat=\"val in titleMapValues track by $index\"><md-checkbox ng-model=\"titleMapValues[$index]\" sf-changed=\"form\" ng-disabled=\"form.readonly\" name=\"{{form.key.slice(-1)[0]}}\" ng-true-value=\"true\" ng-false-value=\"false\" aria-label=\"{{form.title || form.key.slice(-1)[0]}}\"><span ng-bind-html=\"form.titleMap[$index].name\"></span></md-checkbox></div><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></div>");
77
$templateCache.put("decorators/material/chips.html","<div class=\"form-group schema-form-chips {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\"><md-chips sf-field-model=\"\" readonly=\"form.readonly\" flex=\"\" placeholder=\"{{form.title || form.key.slice(-1)[0]}}\"><md-chip-template><strong ng-if=\"!form.template\">{{$chip}}</strong></md-chip-template></md-chips><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></div>");
8-
$templateCache.put("decorators/material/date.html","<md-input-container class=\"schema-form-date {{form.htmlClass}}\"><md-datepicker sf-field-model=\"\" sf-changed=\"form\" sf-type-parser=\"form.schema\" schema-validate=\"form\" id=\"{{form.key.slice(-1)[0]}}\" ng-show=\"form.key\" ng-class=\"form.fieldHtmlClass\" ng-disabled=\"form.readonly\" md-min-date=\"minDate\" md-max-date=\"maxDate\" md-placeholder=\"Enter date\"><label ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</label><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></md-datepicker></md-input-container>");
9-
$templateCache.put("decorators/material/default.html","<md-input-container class=\"schema-form-{{form.type}} {{form.htmlClass}}\" sf-messages=\"\"><label ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</label><input sf-field-model=\"\" ng-show=\"form.key\" type=\"{{form.type}}\" step=\"any\" sf-changed=\"form\" placeholder=\"{{form.placeholder}}\" id=\"{{form.key.slice(-1)[0]}}\" ng-class=\"form.fieldHtmlClass\" sf-type-parser=\"form.schema\" ng-disabled=\"form.readonly\" schema-validate=\"form\" name=\"{{form.key.slice(-1)[0]}}\" aria-describedby=\"{{form.key.slice(-1)[0] + \'Status\'}}\"></md-input-container>");
8+
$templateCache.put("decorators/material/date.html","<div class=\"schema-form-date {{form.htmlClass}}\"><label ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</label><md-datepicker sf-field-model=\"\" sf-changed=\"form\" schema-validate=\"form\" sf-type-parser=\"form.schema\" id=\"{{form.key.slice(-1)[0]}}\" ng-show=\"form.key\" ng-class=\"form.fieldHtmlClass\" ng-disabled=\"form.readonly\" md-placeholder=\"Enter date\" sf-messages=\"\"></md-datepicker></div>");
9+
$templateCache.put("decorators/material/default.html","<md-input-container class=\"schema-form-{{form.type}} {{form.htmlClass}}\" sf-messages=\"\"><label ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</label><input sf-field-model=\"\" ng-show=\"form.key\" type=\"{{form.type}}\" step=\"any\" sf-changed=\"form\" id=\"{{form.key.slice(-1)[0]}}\" ng-class=\"form.fieldHtmlClass\" sf-type-parser=\"form.schema\" ng-disabled=\"form.readonly\" schema-validate=\"form\" name=\"{{form.key.slice(-1)[0]}}\" aria-describedby=\"{{form.key.slice(-1)[0] + \'Status\'}}\"></md-input-container>");
1010
$templateCache.put("decorators/material/fieldset-trcl.html","<fieldset ng-disabled=\"form.readonly\" class=\"standard {{form.htmlClass}}\" flex=\"\"><legend ng-show=\"form.title\">{{ form.title }}</legend><div ng-transclude=\"\"></div></fieldset>");
1111
$templateCache.put("decorators/material/fieldset.html","<fieldset ng-disabled=\"form.readonly\" class=\"standard {{form.htmlClass}}\" flex=\"\"><legend ng-show=\"form.title\">{{ form.title }}</legend></fieldset>");
1212
$templateCache.put("decorators/material/help.html","<div class=\"helpvalue schema-form-helpvalue {{form.htmlClass}}\" ng-bind-html=\"form.helpvalue\"></div>");
@@ -64,6 +64,24 @@ angular.module('schemaForm')
6464
}
6565
};
6666

67+
var mdDatepicker = function(args) {
68+
var mdDatepicker = args.fieldFrag.querySelector('md-datepicker');
69+
if (mdDatepicker) {
70+
if (args.form.onChange) {
71+
mdDatepicker.setAttribute('ng-change', 'args.form.onChange(searchText)');
72+
};
73+
// mdDatepicker.setAttribute('md-items', 'item in $filter(''autocomplete'')(searchText);');
74+
var minDate = args.form.minimum || false;
75+
var maxDate = args.form.maximum || false;
76+
if (minDate) {
77+
mdDatepicker.setAttribute('md-max-date', minDate);
78+
};
79+
if (maxDate) {
80+
mdDatepicker.setAttribute('md-max-date', maxDate);
81+
};
82+
}
83+
};
84+
6785
var tabs = function(args) {
6886
if (args.form.tabs && args.form.tabs.length > 0) {
6987
var tabContainer = args.fieldFrag.querySelector('md-tabs');
@@ -83,19 +101,20 @@ angular.module('schemaForm')
83101
var defaults = [ sfField, ngModel, ngModelOptions, sfMessages, condition ];
84102

85103
decoratorsProvider.defineDecorator('materialDecorator', {
86-
actions: { template: base + 'actions.html', builder: defaults },
104+
actions: { template: base + 'actions.html', builder: [ sfField, simpleTransclusion, condition ] },
87105
array: { template: base + 'array.html', builder: [ sfField, ngModelOptions, ngModel, array, condition ] },
88106
autocomplete: {
89107
template: base + 'autocomplete.html',
90108
builder: [ sfField, ngModel, ngModelOptions, sfMessages, condition, sfAutocomplete ]
91109
},
110+
boolean: { template: base + 'checkbox.html', builder: defaults },
92111
button: { template: base + 'submit.html', builder: defaults },
93112
checkbox: { template: base + 'checkbox.html', builder: defaults },
94113
checkboxes: {
95114
template: base + 'checkboxes.html',
96115
builder: [ sfField, ngModelOptions, ngModel, array, condition ]
97116
},
98-
date: { template: base + 'date.html', builder: defaults },
117+
date: { template: base + 'date.html', builder: [ sfField, ngModel, ngModelOptions, sfMessages, mdDatepicker, condition ] },
99118
'default': { template: base + 'default.html', builder: defaults },
100119
fieldset: { template: base + 'fieldset.html', builder: [ sfField, simpleTransclusion, condition ] },
101120
help: { template: base + 'help.html', builder: defaults },
@@ -139,7 +158,7 @@ angular.module('schemaForm')
139158
}
140159
else {
141160
if (args.form.optionFilter) {
142-
mdAutocomplete.setAttribute('md-items',
161+
mdDatepicker.setAttribute('md-items',
143162
'item in evalExpr("this[\""+form.optionFilter+"\"](\""+searchText+"\")")');
144163
}
145164
}

material-decorator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions.html

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
<div class="btn-group schema-form-actions {{form.htmlClass}}">
2-
<input ng-repeat-start="item in form.items"
3-
type="submit"
4-
class="btn {{ item.style || 'btn-default' }} {{form.fieldHtmlClass}}"
5-
value="{{item.title}}"
6-
ng-if="item.type === 'submit'">
7-
<button ng-repeat-end
8-
class="btn {{ item.style || 'btn-default' }} {{form.fieldHtmlClass}}"
9-
type="button"
10-
ng-disabled="form.readonly"
11-
ng-if="item.type !== 'submit'"
12-
ng-click="buttonClick($event,item)">{{item.title}}</button>
13-
</div>
1+
<section layout="row" class="btn-group schema-form-actions {{form.htmlClass}}"></section>

src/array.html

+27-23
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
<div sf-array="form" class="schema-form-array {{form.htmlClass}}"
2-
ng-model="$$value$$" ng-model-options="form.ngModelOptions">
3-
<h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3>
4-
<ol class="list-group" ng-model="modelArray" ui-sortable>
5-
<li class="list-group-item {{form.fieldHtmlClass}}"
6-
ng-repeat="item in modelArray track by $index">
7-
<md-button ng-hide="form.readonly || form.remove === null"
8-
ng-click="deleteFromArray($index)"
9-
style="position: relative; z-index: 20;"
10-
type="button" class="close pull-right">
11-
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
1+
<div class="schema-form-array {{form.htmlClass}}"
2+
sf-field-model="sf-new-array"
3+
sf-new-array>
4+
<label class="control-label" ng-show="showTitle()">{{ form.title }}</label>
5+
<md-list class="list-group" sf-field-model ui-sortable="form.sortOptions">
6+
<md-list-item layout="row" class="list-group-item"
7+
sf-field-model="ng-repeat"
8+
ng-repeat="item in $$value$$ track by $index"
9+
schema-form-array-items
10+
class="{{form.fieldHtmlClass}}">
11+
<md-button flex="none" flex-order="2"
12+
type="button"
13+
ng-hide="form.readonly || form.remove === null"
14+
ng-click="deleteFromArray($index)"
15+
ng-disabled="form.schema.minItems >= modelArray.length"
16+
class="md-icon-button" aria-label="More"
17+
style="position: relative; z-index: 20;">
18+
<md-icon md-svg-icon="img/icons/ic_clear_black_18px.svg"></md-icon>
1219
</md-button>
13-
<sf-decorator ng-init="arrayIndex = $index" form="copyWithIndex($index)"></sf-decorator>
14-
</li>
15-
</ol>
16-
<div class="clearfix" style="padding: 15px;">
20+
</md-list-item>
21+
</md-list>
22+
<div class="clearfix" style="padding: 15px;" ng-model="modelArray" schema-validate="form">
23+
<div class="help-block"
24+
ng-show="(hasError() && errorMessage(schemaError())) || form.description"
25+
ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div>
26+
1727
<md-button ng-hide="form.readonly || form.add === null"
1828
ng-click="appendToArray()"
29+
ng-disabled="form.schema.maxItems <= modelArray.length"
1930
type="button"
20-
class="btn {{ form.style.add || 'btn-default' }} pull-right">
31+
class="btn md-raised md-primary {{ form.style.add || 'btn-default' }} pull-right">
2132
<i class="glyphicon glyphicon-plus"></i>
2233
{{ form.add || 'Add'}}
2334
</md-button>
2435
</div>
25-
<div ng-messages="ngModel.$error">
26-
<!--
27-
This is a bit of a hack. sf-message does the work, but ng-messages and ng-message
28-
is needed for the styling
29-
-->
30-
<div sf-message ng-message></div>
31-
</div>
3236
</div>

src/date.html

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
<md-input-container class="schema-form-date {{form.htmlClass}}">
1+
<div class="schema-form-date {{form.htmlClass}}">
2+
<label ng-show="showTitle()" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label>
23
<md-datepicker sf-field-model
34
sf-changed="form"
4-
sf-type-parser="form.schema"
55
schema-validate="form"
6+
sf-type-parser="form.schema"
67
id="{{form.key.slice(-1)[0]}}"
78
ng-show="form.key"
89
ng-class="form.fieldHtmlClass"
910
ng-disabled="form.readonly"
10-
md-min-date="minDate"
11-
md-max-date="maxDate"
12-
md-placeholder="Enter date">
13-
<label ng-show="showTitle()" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label>
14-
<div ng-messages="ngModel.$error">
15-
<!--
16-
This is a bit of a hack. sf-message does the work, but ng-messages and ng-message
17-
is needed for the styling
18-
-->
19-
<div sf-message ng-message></div>
20-
</div>
11+
md-placeholder="Enter date" sf-messages>
2112
</md-datepicker>
22-
</md-input-container>
13+
</div>

src/default.html

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
type="{{form.type}}"
2222
step="any"
2323
sf-changed="form"
24-
placeholder="{{form.placeholder}}"
2524
id="{{form.key.slice(-1)[0]}}"
2625
ng-class="form.fieldHtmlClass"
2726
sf-type-parser="form.schema"

0 commit comments

Comments
 (0)