Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix from @mpina83 for obsolete bootstrap decorator init; Fixes #63 #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions angular-schema-form-dynamic-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
root.angularSchemaFormDynamicSelect = factory(root.schemaForm);
}
}(this, function(schemaForm) {
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselect.html","<div ng-controller=\"dynamicSelectController\" class=\"form-group {{form.htmlClass}}\"\n ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n\n <div class=\"form-group {{form.fieldHtmlClass}}\" ng-init=\"populateTitleMap(form)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" ng-model=\"$$value$$\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\"\n data-multiple=\"1\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n data-max-length=\"{{form.options.inlineMaxLength}}\"\n data-max-length-html=\"{{form.options.inlineMaxLengthHtml}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
$templateCache.put("directives/decorators/bootstrap/strap/strapselect.html","<div ng-controller=\"dynamicSelectController\" class=\"form-group {{form.htmlClass}}\"\n ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n\n <div class=\"form-group {{form.fieldHtmlClass}}\" ng-init=\"populateTitleMap(form)\">\n <button ng-if=\"(form.options.multiple == \'true\') || (form.options.multiple == true)\"\n type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" ng-model=\"$$value$$\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\" data-multiple=\"1\" data-max-length=\"{{form.options.inlineMaxLength}}\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n data-max-length-html=\"{{form.options.inlineMaxLengthHtml}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <button ng-if=\"!((form.options.multiple == \'true\') || (form.options.multiple == true))\"\n type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" ng-model=\"$$value$$\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}} </span>\n </div>\n</div>\n\n");}]);
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselect.html","<div ng-controller=\"dynamicSelectController\" class=\"form-group {{form.htmlClass}}\"\n ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n\n <div class=\"form-group {{form.fieldHtmlClass}}\" ng-init=\"populateTitleMap(form)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" sf-field-model=\"\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\"\n data-multiple=\"1\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n data-max-length=\"{{form.options.inlineMaxLength}}\"\n data-max-length-html=\"{{form.options.inlineMaxLengthHtml}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
$templateCache.put("directives/decorators/bootstrap/strap/strapselect.html","<div ng-controller=\"dynamicSelectController\" class=\"form-group {{form.htmlClass}}\"\n ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n\n <div class=\"form-group {{form.fieldHtmlClass}}\" ng-init=\"populateTitleMap(form)\">\n <button ng-if=\"(form.options.multiple == \'true\') || (form.options.multiple == true)\"\n type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" sf-field-model=\"\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\" data-multiple=\"1\" data-max-length=\"{{form.options.inlineMaxLength}}\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n data-max-length-html=\"{{form.options.inlineMaxLengthHtml}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <button ng-if=\"!((form.options.multiple == \'true\') || (form.options.multiple == true))\"\n type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" schema-validate=\"form\" sf-field-model=\"\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-html=\"1\"\n data-placement=\"{{form.options.placement || \'bottom-left\'}}\"\n bs-options=\"item.value as item.name for item in form.titleMap | selectFilter:this:$$value$$:&quot;$$value$$&quot;\"\n bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}} </span>\n </div>\n</div>\n\n");}]);
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("directives/decorators/bootstrap/uiselect/uiselect.html","<div ng-controller=\"dynamicSelectController\" class=\"form-group\"\n ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\"\n ng-init=\"insideModel=$$value$$;\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n\n <div class=\"form-group\">\n <ui-select ng-model=\"select_model.selected\"\n ng-if=\"!(form.options.tagging||false)\" theme=\"bootstrap\" ng-disabled=\"form.disabled\"\n on-select=\"$$value$$=$item.value\" class=\"{{form.options.uiClass}}\">\n <ui-select-match\n placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}\">\n {{select_model.selected.name}}\n </ui-select-match>\n <ui-select-choices refresh=\"populateTitleMap(form, $select.search)\"\n refresh-delay=\"form.options.refreshDelay\" group-by=\"form.options.groupBy\"\n repeat=\"item in form.titleMap | propsFilter: {name: $select.search, description: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }\">\n <div ng-bind-html=\"item.name | highlight: $select.search\"></div>\n <div ng-if=\"item.description\">\n <span ng-bind-html=\"\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\'))+ \'</small>\'\"></span>\n </div>\n </ui-select-choices>\n </ui-select>\n <ui-select ng-controller=\"dynamicSelectController\" ng-model=\"select_model.selected\"\n ng-if=\"(form.options.tagging||false) && !(form.options.groupBy || false)\"\n tagging=\"form.options.tagging||false\" tagging-label=\"form.options.taggingLabel\"\n tagging-tokens=\"form.options.taggingTokens\"\n theme=\"bootstrap\" ng-disabled=\"form.disabled\" on-select=\"$$value$$=$item.value\"\n class=\"{{form.options.uiClass}}\">\n <ui-select-match\n placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}\">\n {{select_model.selected.name}}&nbsp;\n <small>{{(select_model.selected.isTag===true ? form.options.taggingLabel : \'\')}}</small>\n </ui-select-match>\n <!--repeat code because tagging does not display properly under group by but is still useful -->\n <ui-select-choices refresh=\"populateTitleMap(form, $select.search)\"\n refresh-delay=\"form.options.refreshDelay\"\n repeat=\"item in form.titleMap | propsFilter: {name: $select.search, description: (form.options.searchDescription===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }\">\n <div ng-if=\"item.isTag\"\n ng-bind-html=\"\'<div>\' + (item.name | highlight: $select.search) + \' \' + form.options.taggingLabel + \'</div><div class=&quot;divider&quot;></div>\'\"></div>\n <div ng-if=\"!item.isTag\" ng-bind-html=\"item.name + item.isTag| highlight: $select.search\"></div>\n <div ng-if=\"item.description\">\n <span ng-bind-html=\"\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\')) + \'</small>\'\"></span>\n </div>\n </ui-select-choices>\n </ui-select>\n\n <!--repeat code because tagging does not display properly under group by but is still useful -->\n\n <ui-select ng-controller=\"dynamicSelectController\" ng-model=\"select_model.selected\"\n ng-if=\"(form.options.tagging||false) && (form.options.groupBy || false)\"\n tagging=\"form.options.tagging||false\" tagging-label=\"form.options.taggingLabel\"\n tagging-tokens=\"form.options.taggingTokens\"\n theme=\"bootstrap\" ng-disabled=\"form.disabled\" on-select=\"$$value$$=$item.value\"\n class=\"{{form.options.uiClass}}\">\n <ui-select-match\n placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}\">\n {{select_model.selected.name}}&nbsp;\n <small>{{(select_model.selected.isTag===true ? form.options.taggingLabel : \'\')}}</small>\n </ui-select-match>\n <ui-select-choices group-by=\"form.options.groupBy\"\n refresh=\"populateTitleMap(form, $select.search)\"\n refresh-delay=\"form.options.refreshDelay\"\n repeat=\"item in form.titleMap | propsFilter: {name: $select.search, description: (form.options.searchDescription===true ? $select.search : \'NOTSEARCHINGFORTHIS\') }\">\n <div ng-if=\"item.isTag\"\n ng-bind-html=\"\'<div>\' + (item.name | highlight: $select.search) + \' \' + form.options.taggingLabel + \'</div><div class=&quot;divider&quot;></div>\'\"></div>\n <div ng-if=\"!item.isTag\" ng-bind-html=\"item.name + item.isTag| highlight: $select.search\"></div>\n <div ng-if=\"item.description\">\n <span ng-bind-html=\"\'<small>\' + (\'\'+item.description | highlight: (form.options.searchDescriptions===true ? $select.search : \'NOTSEARCHINGFORTHIS\')) + \'</small>\'\"></span>\n </div>\n </ui-select-choices>\n </ui-select>\n\n <input\n type=\"hidden\"\n name=\"{{form.key.slice(-1)[0]}}\"\n toggle-single-model\n sf-changed=\"form\"\n ng-model=\"insideModel\"\n schema-validate=\"form\"/>\n\n <span ng-if=\"form.feedback !== false\"\n class=\"form-control-feedback\"\n id=\"{{form.key.slice(-1)[0] + \'Status\'}}\"\n ng-class=\"evalInScope(form.feedback) || {\'glyphicon\': true, \'glyphicon-ok\': hasSuccess(), \'glyphicon-remove\': hasError() }\"></span>\n\n <div class=\"help-block\" sf-message=\"form.description\"></div>\n\n </div>\n</div>\n");
$templateCache.put("directives/decorators/bootstrap/uiselect/uiselectmultiple.html","\n<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess(), \'has-feedback\': form.feedback !== false}\"\n ng-controller=\"dynamicSelectController\" ng-init=\"$$value$$=$$value$$||[];uiMultiSelectInitInternalModel($$value$$)\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\">\n <ui-select multiple sortable-options=\"{{form.sortableOptions}}\" ng-model=\"internalModel\" theme=\"bootstrap\"\n on-select=\"$$value$$.push($item.value)\" on-remove=\"$$value$$.splice($$value$$.indexOf($item.value), 1)\"\n class=\"{{form.options.uiClass}}\">\n <ui-select-match placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\' | translate)}}\">{{$item.name}}</ui-select-match>\n <ui-select-choices repeat=\"item in form.titleMap | propsFilter: {name: $select.search}\"\n refresh=\"populateTitleMap(form, $select.search)\"\n refresh-delay=\"form.options.refreshDelay\"\n group-by=\"form.options.groupBy\">\n <div ng-bind-html=\"item.name | highlight: $select.search\"></div>\n </ui-select-choices>\n </ui-select>\n <span ng-if=\"form.feedback !== false\"\n class=\"form-control-feedback\"\n ng-class=\"evalInScope(form.feedback) || {\'glyphicon\': true, \'glyphicon-ok\': hasSuccess(), \'glyphicon-remove\': hasError() }\"></span>\n <div class=\"help-block\"\n ng-show=\"(hasError() && errorMessage(schemaError())) || form.description\"\n ng-bind-html=\"(hasError() && errorMessage(schemaError())) || form.description\"></div>\n </div>\n</div>\n");}]);
angular.module('schemaForm').config(
['schemaFormProvider', 'schemaFormDecoratorsProvider', 'sfPathProvider',
function (schemaFormProvider, schemaFormDecoratorsProvider, sfPathProvider) {
['schemaFormProvider', 'schemaFormDecoratorsProvider', 'sfPathProvider', 'sfBuilderProvider',
function (schemaFormProvider, schemaFormDecoratorsProvider, sfPathProvider, sfBuilderProvider) {

var select = function (name, schema, options) {
if ((schema.type === 'string') && ("enum" in schema)) {
Expand All @@ -26,11 +26,28 @@ angular.module('schemaForm').config(
};

schemaFormProvider.defaults.string.unshift(select);

// Building up new angular schema for builders;

var simpleTransclusion = sfBuilderProvider.builders.simpleTransclusion;
var ngModelOptions = sfBuilderProvider.builders.ngModelOptions;
var ngModel = sfBuilderProvider.builders.ngModel;
var sfField = sfBuilderProvider.builders.sfField;
var condition = sfBuilderProvider.builders.condition;
var array = sfBuilderProvider.builders.array;
var defaults = [sfField, ngModel, ngModelOptions, condition];

//Add to the bootstrap directive
schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'strapselect',
'directives/decorators/bootstrap/strap/strapselect.html');

/*schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'strapselect',
'directives/decorators/bootstrap/strap/strapselect.html');*/

//Add to the bootstrap directive with non deprecated methods
schemaFormDecoratorsProvider.defineAddOn(
'bootstrapDecorator',
'strapselect',
'directives/decorators/bootstrap/strap/strapselect.html',
defaults
);

schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'strapmultiselect',
'directives/decorators/bootstrap/strap/strapmultiselect.html');

Expand All @@ -39,17 +56,24 @@ angular.module('schemaForm').config(

schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'strapmultiselectdynamic',
'directives/decorators/bootstrap/strap/strapmultiselect.html');



// UI SELECT
//Add to the bootstrap directive
schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'uiselect',
'directives/decorators/bootstrap/uiselect/uiselect.html');


/*schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'uiselect',
'directives/decorators/bootstrap/uiselect/uiselect.html');*/

//Add to the bootstrap directive with non deprecated methods
schemaFormDecoratorsProvider.defineAddOn(
'bootstrapDecorator',
'uiselect',
'directives/decorators/bootstrap/uiselect/uiselect.html',
defaults
);

schemaFormDecoratorsProvider.addMapping('bootstrapDecorator', 'uiselectmultiple',
'directives/decorators/bootstrap/uiselect/uiselectmultiple.html');



}])
.directive("toggleSingleModel", function() {
Expand Down