forked from nvdnkpr/angular-schema-form-ui-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-ui-select.min.js
1 lines (1 loc) · 10.1 KB
/
bootstrap-ui-select.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" ng-controller="UiSelectController"><ui-select multiple="" sortable-options="{{form.sortableOptions}}" ng-if="!(form.options.tagging||false)" 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 class="ui-select-match" placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{$item.label}}</ui-select-match><ui-select-choices class="ui-select-choices" refresh="fetchResult(form.schema, form.options, $select.search)" refresh-delay="form.options.refreshDelay" group-by="form.options.groupBy" repeat="item in form.schema.items | propsFilter: {label: $select.search, description: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }"><div ng-bind-html="item.label | highlight: $select.search"></div><div ng-if="item.description"><span ng-bind-html="\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\'))+ \'</small>\'"></span></div></ui-select-choices></ui-select><ui-select ng-controller="UiSelectController" multiple="" ng-if="(form.options.tagging||false) && !(form.options.groupBy || false)" tagging="form.options.tagging||false" tagging-label="form.options.taggingLabel" tagging-tokens="form.options.taggingTokens" 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 class="ui-select-match" placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{$item.label}} <small>{{($item.isTag===true ? form.options.taggingLabel : \'\')}}</small></ui-select-match><ui-select-choices class="ui-select-choices" refresh-delay="form.options.refreshDelay" refresh="fetchResult(form.schema, form.options, $select.search)" repeat="item in form.schema.items | propsFilter: {label: $select.search, description: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }"><div ng-if="item.isTag" ng-bind-html="\'<div>\' + (item.label | highlight: $select.search) + \' \' + form.options.taggingLabel + \'</div><div class="divider"></div>\'"></div><div ng-if="!item.isTag" ng-bind-html="item.label + item.isTag | highlight: $select.search"></div><div ng-if="item.description"><span ng-bind-html="\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\')) + \'</small>\'"></span></div></ui-select-choices></ui-select><ui-select ng-controller="UiSelectController" multiple="" ng-if="(form.options.tagging||false) && (form.options.groupBy || false)" tagging="form.options.tagging||false" tagging-label="form.options.taggingLabel" tagging-tokens="form.options.taggingTokens" 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 class="ui-select-match" placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{$item.label}} <small>{{($item.isTag===true ? form.options.taggingLabel : \'\')}}</small></ui-select-match><ui-select-choices class="ui-select-choices" group-by="form.options.groupBy" refresh-delay="form.options.refreshDelay" refresh="fetchResult(form.schema, form.options, $select.search)" repeat="item in form.schema.items | propsFilter: {label: $select.search, description: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }"><div ng-if="item.isTag" ng-bind-html="\'<div>\' + (item.label | highlight: $select.search) + \' \' + form.options.taggingLabel + \'</div><div class="divider"></div>\'"></div><div ng-if="!item.isTag" ng-bind-html="item.label + item.isTag | highlight: $select.search"></div><div ng-if="item.description"><span ng-bind-html="\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\')) + \'</small>\'"></span></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 {{form.htmlClass}}" ng-class="{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}" ng-init="form_key = form.key"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><ui-select ng-model="select_model.selected" ng-controller="UiSelectController" theme="bootstrap" ng-disabled="form.disabled" on-select="$$value$$=$item.value;onSelect($item.value, form.options)" class="{{form.options.uiClass}}"><ui-select-match class="ui-select-match" placeholder="{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}">{{select_model.selected.label}}</ui-select-match><ui-select-choices class="ui-select-choices" refresh="fetchResult(form.schema, form.options, $select.search)" refresh-delay="form.options.refreshDelay" group-by="form.options.groupBy" repeat="item in form.schema.items | propsFilter: {label: $select.search, description: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }"><div ng-bind-html="item.label | highlight: $select.search"></div><div ng-if="item.description"><span ng-bind-html="\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\'))+ \'</small>\'"></span></div></ui-select-choices></ui-select><span ng-if="form.feedback !== false" class="form-control-feedback" ng-class="evalInScope(form.feedback) || {\'glyphicon\': true, \'glyphicon-ok\': form.disableSuccessState !== true && hasSuccess(), \'glyphicon-remove\': form.disableErrorState !== true && hasError() }" aria-hidden="true"></span><div class="help-block" sf-message="form.description"></div></div>')}]),angular.module("schemaForm").config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider",function(e,t,s){var o=function(t,o,i){if("string"===o.type&&"uiselect"==o.format){var l=e.stdFormObj(t,o,i);return l.key=i.path,l.type="uiselect",i.lookup[s.stringify(i.path)]=l,l}};e.defaults.string.unshift(o);var o=function(t,o,i){if("number"===o.type&&"uiselect"==o.format){var l=e.stdFormObj(t,o,i);return l.key=i.path,l.type="uiselect",i.lookup[s.stringify(i.path)]=l,l}};e.defaults.number.unshift(o);var i=function(t,o,i){if("array"===o.type&&"uiselect"==o.format){var l=e.stdFormObj(t,o,i);return l.key=i.path,l.type="uimultiselect",i.lookup[s.stringify(i.path)]=l,l}};e.defaults.array.unshift(i),t.addMapping("bootstrapDecorator","uiselect","directives/decorators/bootstrap/uiselect/single.html"),t.createDirective("uiselect","directives/decorators/bootstrap/uiselect/single.html"),t.addMapping("bootstrapDecorator","uimultiselect","directives/decorators/bootstrap/uiselect/multi.html"),t.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))})}]}}).filter("whereMulti",function(){return function(e,t,s){var o=[];return angular.isArray(s)?s.forEach(function(s){for(var i=0;i<e.length;i++)if(s==e[i][t]){o.push(e[i]);break}}):o=e,o}}).filter("propsFilter",function(){return function(e,t){var s=[];return angular.isArray(e)?e.forEach(function(e){for(var o=!1,i=Object.keys(t),l=0;l<i.length;l++){var r=i[l];if(e.hasOwnProperty(r)){var a=t[r].toLowerCase();if(0===e[r].toString().toLowerCase().indexOf(a)||-1!==e[r].toString().toLowerCase().indexOf(" "+a)){o=!0;break}}}o&&s.push(e)}):s=e,s}}).controller("UiSelectController",["$scope","$http",function(e,t){e.select_model={},e.$on("clear-select-model",function(t,s){void 0!==e.select_model.selected&&e.form_key.includes(s)&&e.$evalAsync(function(){e.select_model.selected=void 0})}),e.onSelect=function(e,t){if(t&&t.onSelect){var s="function"==typeof t.onSelect?t.onSelect:new Function(t.onSelect);s(e,t)}},e.fetchResult=function(e,s,o){if(s)if(s.callback){var i="function"==typeof s.callback?s.callback:new Function(s.callback);e.items=i(e,s,o)}else{if(s.http_post)return t.post(s.http_post.url,s.http_post.parameter).then(function(t){e.items=t.data},function(e,t){alert("Loading select items failed (URL: '"+String(s.http_post.url)+"' Parameter: "+String(s.http_post.parameter)+"\nError: "+t)});if(s.http_get)return t.get(s.http_get.url,s.http_get.parameter).then(function(t){e.items=t.data},function(e,t){alert("Loading select items failed (URL: '"+String(s.http_get.url)+"\nError: "+t)});if(s.async){var i="function"==typeof s.async.call?s.async.call:new Function(s.async.call);return i(e,s,o).then(function(t){e.items=t.data},function(e,t){alert("Loading select items failed(Options: '"+String(s)+"\nError: "+t)})}}}}]);