-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathschema-form-uiselect.min.js
1 lines (1 loc) · 5.52 KB
/
schema-form-uiselect.min.js
1
angular.module("schemaForm").run(["$templateCache",function(e){e.put("directives/decorators/bootstrap/uiselect/multi.html",'<div class="form-group" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" ng-init="form.select_models=(form.schema.items| whereMulti : \'value\' : ($$value$$||[]))"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><div class="form-group"><ui-select multiple="" sortable-options="{{form.sortableOptions}}" ng-model="form.select_models" theme="bootstrap" on-select="$$value$$.push($item.value)" on-remove="$$value$$.splice($$value$$.indexOf($item.value), 1)" class="{{form.options.uiClass}}"><ui-select-match placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{$item.label}}</ui-select-match><ui-select-choices repeat="item in form.schema.items | propsFilter: {label: $select.search}" refresh="form.options.refreshMethod(form.schema, $select.search)" refresh-delay="form.options.refreshDelay"><div ng-bind-html="item.label | highlight: $select.search"></div></ui-select-choices></ui-select><input toggle-model="" type="hidden" ng-model="insideModel" sf-changed="form" schema-validate="form"><span ng-if="form.feedback !== false" class="form-control-feedback" ng-class="evalInScope(form.feedback) || {\'glyphicon\': true, \'glyphicon-ok\': hasSuccess(), \'glyphicon-remove\': hasError() }"></span><div class="help-block" ng-show="(hasError() && errorMessage(schemaError())) || form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div></div></div>'),e.put("directives/decorators/bootstrap/uiselect/single.html",'<div class="form-group" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" ng-init="select_models=(form.schema.items | where : {value: $$value$$})"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><div class="form-group" ng-init="select_model.selected=select_models[0]"><ui-select ng-model="select_model.selected" theme="bootstrap" ng-disabled="form.disabled" on-select="$$value$$=$item.value" class="{{form.options.uiClass}}"><ui-select-match placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{select_model.selected.label}}</ui-select-match><ui-select-choices repeat="item in form.schema.items | propsFilter: {label: $select.search}" refresh="form.options.refreshMethod(form.schema, $select.search)" refresh-delay="form.options.refreshDelay"><div ng-bind-html="item.label | highlight: $select.search"></div></ui-select-choices></ui-select><input type="hidden" toggle-single-model="" sf-changed="form" ng-model="insideModel" schema-validate="form"><span ng-if="form.feedback !== false" class="form-control-feedback" ng-class="evalInScope(form.feedback) || {\'glyphicon\': true, \'glyphicon-ok\': hasSuccess(), \'glyphicon-remove\': hasError() }"></span><div class="help-block" ng-show="(hasError() && errorMessage(schemaError())) || form.description" ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div></div></div>')}]),angular.module("schemaForm-uiselect",["schemaForm","ui.select"]).config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider",function(e,r,s){var t=function(r,t,o){if("string"===t.type&&"uiselect"==t.format){var l=e.stdFormObj(r,t,o);return l.key=o.path,l.type="uiselect",o.lookup[s.stringify(o.path)]=l,l}};e.defaults.string.unshift(t);var t=function(r,t,o){if("number"===t.type&&"uiselect"==t.format){var l=e.stdFormObj(r,t,o);return l.key=o.path,l.type="uiselect",o.lookup[s.stringify(o.path)]=l,l}};e.defaults.number.unshift(t);var o=function(r,t,o){if("array"===t.type&&"uiselect"==t.format){var l=e.stdFormObj(r,t,o);return l.key=o.path,l.type="uimultiselect",o.lookup[s.stringify(o.path)]=l,l}};e.defaults.array.unshift(o),r.addMapping("bootstrapDecorator","uiselect","directives/decorators/bootstrap/uiselect/single.html"),r.createDirective("uiselect","directives/decorators/bootstrap/uiselect/single.html"),r.addMapping("bootstrapDecorator","uimultiselect","directives/decorators/bootstrap/uiselect/multi.html"),r.createDirective("uimultiselect","directives/decorators/bootstrap/uiselect/multi.html")}]).directive("toggleSingleModel",function(){return{require:"ngModel",restrict:"A",scope:{},replace:!0,controller:["$scope",function(e){e.$parent.$watch("select_model.selected",function(){void 0!=e.$parent.select_model.selected&&(e.$parent.insideModel=e.$parent.select_model.selected.value,e.$parent.ngModel.$setViewValue(e.$parent.select_model.selected.value))})}]}}).directive("toggleModel",function(){return{require:"ngModel",restrict:"A",scope:{},replace:!0,controller:["$scope",function(e){e.$parent.$watch("form.select_models",function(){0==e.$parent.form.select_models.length?(e.$parent.insideModel=e.$parent.$$value$$,void 0!=e.$parent.ngModel.$viewValue&&e.$parent.ngModel.$setViewValue(e.$parent.form.select_models)):(e.$parent.insideModel=e.$parent.form.select_models,e.$parent.ngModel.$setViewValue(e.$parent.form.select_models))},!0)}]}}).filter("whereMulti",function(){return function(e,r,s){var t=[];return angular.isArray(s)?s.forEach(function(s){for(var o=0;o<e.length;o++)if(s==e[o][r]){t.push(e[o]);break}}):t=e,t}}).filter("propsFilter",function(){return function(e,r){var s=[];return angular.isArray(e)?e.forEach(function(e){for(var t=!1,o=Object.keys(r),l=0;l<o.length;l++){var a=o[l],c=r[a].toLowerCase();if(-1!==e[a].toString().toLowerCase().indexOf(c)){t=!0;break}}t&&s.push(e)}):s=e,s}});