@@ -6,7 +6,7 @@ $templateCache.put("decorators/material/checkbox.html","<div class=\"checkbox sc
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>" ) ;
88$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>" ) ;
9+ $templateCache . put ( "decorators/material/default.html" , "<md-input-container class=\"schema-form-{{form.type}} {{form.htmlClass}}\" ng-class=\"{\'md-input-has-value\':model[\'{{form.key.slice(-1)[0]}}\']}\" 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>" ) ;
@@ -16,7 +16,7 @@ $templateCache.put("decorators/material/radios.html","<div class=\"form-group sc
1616$templateCache . put ( "decorators/material/section.html" , "<div class=\"schema-form-section {{form.htmlClass}}\"></div>" ) ;
1717$templateCache . put ( "decorators/material/select.html" , "<md-input-container class=\"form-group {{form.htmlClass}} schema-form-select\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\"><label ng-show=\"showTitle()\">{{form.title}}</label><md-select sf-field-model=\"\"><md-optgroup ng-repeat-start=\"(key, opt) in form.titleMap | orderBy:\'group\' as optGroups\" ng-if=\"opt.group && opt.group != optGroups[key-1].group\" label=\"{{opt.group}}\"><md-option ng-repeat=\"(key, filtered) in form.titleMap | filter: {group: opt.group} | orderBy:\'name\' as opts\" ng-value=\"filtered.value\">{{filtered.name}}</md-option></md-optgroup><md-option ng-repeat-end=\"\" ng-if=\"!opt.group\" ng-value=\"opt.value\">{{opt.name}}</md-option></md-select><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></md-input-container>" ) ;
1818$templateCache . put ( "decorators/material/submit.html" , "<section class=\"schema-form-submit {{form.htmlClass}}\"><md-button class=\"md-raised {{ form.style || \'md-primary\' }} {{form.fieldHtmlClass}}\" ng-disabled=\"form.readonly\">{{form.title}}</md-button></section>" ) ;
19- $templateCache . put ( "decorators/material/switch.html" , "<md-input-container class=\"schema-form-switch {{form.htmlClass}}\"><md-switch sf-field-model=\"\" sf-changed=\"form\" sf-type-parser=\"form.schema\" schema-validate=\"form\" id=\"{{form.key.slice(-1)[0]}}\" aria-label=\"{{form.title}}\" ng-true-value=\"\'yup\'\" ng-false-value=\"\'nope\'\" ng- show=\"form.key\" ng-class=\"form.fieldHtmlClass\" ng-disabled=\"form.readonly\"><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-switch></md-input-container>" ) ;
19+ $templateCache . put ( "decorators/material/switch.html" , "<md-input-container class=\"schema-form-switch {{form.htmlClass}}\"><md-switch sf-field-model=\"\" sf-changed=\"form\" sf-type-parser=\"form.schema\" schema-validate=\"form\" id=\"{{form.key.slice(-1)[0]}}\" aria-label=\"{{form.title}}\" ng-show=\"form.key\" ng-class=\"form.fieldHtmlClass\" ng-disabled=\"form.readonly\"><span ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</span ><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></md-switch></md-input-container>" ) ;
2020$templateCache . put ( "decorators/material/tabarray.html" , "<div sf-array=\"form\" ng-init=\"selected = { tab: 0 }\" class=\"clearfix schema-form-tabarray schema-form-tabarray-{{form.tabType || \'left\'}} {{form.htmlClass}}\"><div ng-if=\"!form.tabType || form.tabType !== \'right\'\" ng-class=\"{\'col-xs-3\': !form.tabType || form.tabType === \'left\'}\"><ul class=\"nav nav-tabs\" ng-class=\"{ \'tabs-left\': !form.tabType || form.tabType === \'left\'}\"><li ng-repeat=\"item in modelArray track by $index\" ng-click=\"$event.preventDefault() || (selected.tab = $index)\" ng-class=\"{active: selected.tab === $index}\"><a href=\"#\">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide=\"form.readonly\" ng-click=\"$event.preventDefault() || (selected.tab = appendToArray().length - 1)\"><a href=\"#\"><i class=\"glyphicon glyphicon-plus\"></i> {{ form.add || \'Add\'}}</a></li></ul></div><div ng-class=\"{\'col-xs-9\': !form.tabType || form.tabType === \'left\' || form.tabType === \'right\'}\"><div class=\"tab-content {{form.fieldHtmlClass}}\"><div class=\"tab-pane clearfix\" ng-repeat=\"item in modelArray track by $index\" ng-show=\"selected.tab === $index\" ng-class=\"{active: selected.tab === $index}\"><sf-decorator ng-init=\"arrayIndex = $index\" form=\"copyWithIndex($index)\"></sf-decorator><button ng-hide=\"form.readonly\" ng-click=\"selected.tab = deleteFromArray($index).length - 1\" type=\"button\" class=\"btn {{ form.style.remove || \'btn-default\' }} pull-right\"><i class=\"glyphicon glyphicon-trash\"></i> {{ form.remove || \'Remove\'}}</button></div></div></div><div ng-if=\"form.tabType === \'right\'\" class=\"col-xs-3\"><ul class=\"nav nav-tabs tabs-right\"><li ng-repeat=\"item in modelArray track by $index\" ng-click=\"$event.preventDefault() || (selected.tab = $index)\" ng-class=\"{active: selected.tab === $index}\"><a href=\"#\">{{interp(form.title,{\'$index\':$index, value: item}) || $index}}</a></li><li ng-hide=\"form.readonly\" ng-click=\"$event.preventDefault() || appendToArray()\"><a href=\"#\"><i class=\"glyphicon glyphicon-plus\"></i> {{ form.add || \'Add\'}}</a></li></ul></div></div>" ) ;
2121$templateCache . put ( "decorators/material/tabs.html" , "<div sf-field-model=\"\" class=\"schema-form-tabs {{form.htmlClass}}\"><md-tabs md-dynamic-height=\"\" md-selected=\"selected\" md-autoselect=\"\" ng-init=\"selected = 0\"></md-tabs></div>" ) ;
2222$templateCache . put ( "decorators/material/textarea.html" , "<md-input-container class=\"{{form.htmlClass}} schema-form-textarea\"><label ng-show=\"showTitle()\" for=\"{{form.key.slice(-1)[0]}}\">{{form.title}}</label> <textarea ng-class=\"form.fieldHtmlClass\" id=\"{{form.key.slice(-1)[0]}}\" sf-changed=\"form\" ng-disabled=\"form.readonly\" sf-field-model=\"\" schema-validate=\"form\" name=\"{{form.key.slice(-1)[0]}}\"></textarea><div ng-messages=\"ngModel.$error\"><div sf-message=\"\" ng-message=\"\"></div></div></md-input-container>" ) ; } ] ) ;
@@ -50,17 +50,28 @@ angular.module('schemaForm')
5050 if ( mdAutocompleteFrag ) {
5151 if ( args . form . onChange ) {
5252 mdAutocompleteFrag . setAttribute ( 'md-selected-item-change' , 'args.form.onChange(searchText)' ) ;
53- } ;
53+ }
5454 if ( args . form . onChange ) {
5555 mdAutocompleteFrag . setAttribute ( 'md-search-text-change' , 'args.form.onChange(searchText)' ) ;
56- } ;
56+ }
5757 // mdAutocompleteFrag.setAttribute('md-items', 'item in $filter(''autocomplete'')(searchText);');
5858 var minLength = args . form . minLength || 1 ;
5959 var maxLength = args . form . maxLength || false ;
6060 mdAutocompleteFrag . setAttribute ( 'md-min-length' , minLength ) ;
6161 if ( maxLength ) {
6262 mdAutocompleteFrag . setAttribute ( 'md-max-length' , maxLength ) ;
63- } ;
63+ }
64+ }
65+ } ;
66+
67+ var mdSwitch = function ( args ) {
68+ var mdSwitchFrag = args . fieldFrag . querySelector ( 'md-switch' ) ;
69+ if ( args . form . schema . titleMap ) {
70+ mdSwitchFrag . setAttribute ( 'ng-true-value' , args . form . schema . titleMap . true ) ;
71+ mdSwitchFrag . setAttribute ( 'ng-false-value' , args . form . schema . titleMap . false ) ;
72+ }
73+ if ( args . form . schema . ink ) {
74+ mdSwitchFrag . setIdAttribute ( 'md-no-ink' , args . form . schema . ink ) ;
6475 }
6576 } ;
6677
@@ -69,16 +80,16 @@ angular.module('schemaForm')
6980 if ( mdDatepickerFrag ) {
7081 if ( args . form . onChange ) {
7182 mdDatepickerFrag . setAttribute ( 'ng-change' , 'args.form.onChange(searchText)' ) ;
72- } ;
83+ }
7384 // mdDatepickerFrag.setAttribute('md-items', 'item in $filter(''autocomplete'')(searchText);');
7485 var minDate = args . form . minimum || false ;
7586 var maxDate = args . form . maximum || false ;
7687 if ( minDate ) {
7788 mdDatepickerFrag . setAttribute ( 'md-max-date' , minDate ) ;
78- } ;
89+ }
7990 if ( maxDate ) {
8091 mdDatepickerFrag . setAttribute ( 'md-max-date' , maxDate ) ;
81- } ;
92+ }
8293 }
8394 } ;
8495
@@ -131,7 +142,11 @@ angular.module('schemaForm')
131142 submit : { template : base + 'submit.html' , builder : defaults } ,
132143 tabs : { template : base + 'tabs.html' , builder : [ sfField , mdTabs , condition ] } ,
133144 tabarray : { template : base + 'tabarray.html' , builder : [ sfField , ngModelOptions , ngModel , array , condition ] } ,
134- textarea : { template : base + 'textarea.html' , builder : defaults }
145+ textarea : { template : base + 'textarea.html' , builder : defaults } ,
146+ switch : {
147+ template : base + 'switch.html' ,
148+ builder : [ sfField , ngModel , ngModelOptions , sfMessages , condition , mdSwitch ]
149+ }
135150 } ) ;
136151
137152 /**
0 commit comments