Skip to content

Commit 0e47834

Browse files
committed
fix(directives) Remove the inadvertent copied in break from the loop.
1 parent eda5925 commit 0e47834

File tree

7 files changed

+96
-34
lines changed

7 files changed

+96
-34
lines changed

dist/forms-angular-with-bs2.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,18 +5346,20 @@ form .schema-foot blockquote {
53465346
border-color: rgba(0, 0, 0, 0.15);
53475347
}
53485348
form .schema-head {
5349-
margin-top: 0;
5349+
margin-top: 8px;
53505350
margin-bottom: 5px;
53515351
border: 1px solid #ddd;
53525352
padding: 4px 180px;
53535353
}
53545354
form .sub-doc {
5355-
padding: 0 5px 0 0;
5355+
padding: 5px 5px 2px 0;
53565356
width: 97%;
53575357
margin-bottom: 3px;
5358+
position: relative;
53585359
}
53595360
form .sub-doc-btns {
5360-
margin-left: 15px;
5361+
position: absolute;
5362+
right: 8px;
53615363
}
53625364
form .schema-foot {
53635365
padding: 5px 180px;

dist/forms-angular-with-bs2.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/forms-angular-with-bs3.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5891,18 +5891,20 @@ form .schema-foot blockquote {
58915891
border-color: rgba(0, 0, 0, 0.15);
58925892
}
58935893
form .schema-head {
5894-
margin-top: 0;
5894+
margin-top: 8px;
58955895
margin-bottom: 5px;
58965896
border: 1px solid #ddd;
58975897
padding: 4px 180px;
58985898
}
58995899
form .sub-doc {
5900-
padding: 0 5px 0 0;
5900+
padding: 5px 5px 2px 0;
59015901
width: 97%;
59025902
margin-bottom: 3px;
5903+
position: relative;
59035904
}
59045905
form .sub-doc-btns {
5905-
margin-left: 15px;
5906+
position: absolute;
5907+
right: 8px;
59065908
}
59075909
form .schema-foot {
59085910
padding: 5px 180px;
@@ -6045,6 +6047,9 @@ form .schema-foot {
60456047
border: 1px solid #e3e3e3;
60466048
border-radius: 4px;
60476049
}
6050+
form .sub-doc {
6051+
margin-left: 12px;
6052+
}
60486053
form .checkbox input[type="checkbox"] {
60496054
margin-left: -5px;
60506055
}

dist/forms-angular-with-bs3.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/forms-angular.js

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! forms-angular 2015-01-28 */
1+
/*! forms-angular 2015-02-04 */
22
'use strict';
33

44
var formsAngular = angular.module('formsAngular', [
@@ -591,29 +591,29 @@ formsAngular
591591
'<div ng-form class="' + (cssFrameworkService.framework() === 'bs2' ? 'row-fluid ' : '') +
592592
convertFormStyleToClass(info.formStyle) + '" name="form_' + niceName + '{{$index}}" class="sub-doc well" id="' + info.id + 'List_{{$index}}" ' +
593593
' ng-repeat="subDoc in ' + (options.model || 'record') + '.' + info.name + ' track by $index">' +
594-
' <div class="' + (cssFrameworkService.framework() === 'bs2' ? 'row-fluid' : 'row') + ' sub-doc">' +
595-
' <div class="pull-left">' + processInstructions(info.schema, false, {subschema: true, formstyle: info.formStyle, model: options.model, subschemaRoot: info.name}) +
596-
' </div>';
597-
594+
' <div class="' + (cssFrameworkService.framework() === 'bs2' ? 'row-fluid' : 'row') + ' sub-doc">';
598595
if (!info.noRemove || info.customSubDoc) {
599-
template += ' <div class="pull-left sub-doc-btns">';
596+
template += ' <div class="sub-doc-btns">';
600597
if (info.customSubDoc) {
601598
template += info.customSubDoc;
602599
}
603600
if (!info.noRemove) {
604601
if (cssFrameworkService.framework() === 'bs2') {
605602
template += ' <button name="remove_' + info.id + '_btn" class="remove-btn btn btn-mini form-btn" ng-click="remove(\'' + info.name + '\',$index,$event)">' +
606-
' <i class="icon-minus">';
603+
' <i class="icon-minus">';
607604

608605
} else {
609606
template += ' <button name="remove_' + info.id + '_btn" class="remove-btn btn btn-default btn-xs form-btn" ng-click="remove(\'' + info.name + '\',$index,$event)">' +
610607
' <i class="glyphicon glyphicon-minus">';
611608
}
612609
template += ' </i> Remove' +
613-
' </button>';
610+
' </button>';
614611
}
615612
template += ' </div> ';
616613
}
614+
615+
template += processInstructions(info.schema, false, {subschema: true, formstyle: info.formStyle, model: options.model, subschemaRoot: info.name});
616+
617617
template += ' </div>' +
618618
'</div>';
619619
if (!info.noAdd || info.customFooter) {
@@ -729,6 +729,12 @@ formsAngular
729729
}
730730
}
731731
}
732+
for (prop in options) {
733+
if (options.hasOwnProperty(prop) && prop[0] !== '$') {
734+
newElement += ' fng-opt-' + prop + '="' + options[prop].toString().replace(/"/g,'&quot;') + '"';
735+
}
736+
}
737+
732738
newElement += '></' + directiveName + '>';
733739
result += newElement;
734740
callHandleField = false;
@@ -1217,26 +1223,29 @@ formsAngular.provider('routingService', [ '$injector', '$locationProvider', func
12171223
var lastRoute = null,
12181224
lastObject = {};
12191225

1220-
function _setUpNgRoutes(routes) {
1226+
function _setUpNgRoutes(routes, prefix, additional) {
1227+
prefix = prefix || '';
12211228
angular.forEach(routes, function (routeSpec) {
1222-
_routeProvider.when(config.prefix + routeSpec.route, routeSpec.options || {templateUrl: routeSpec.templateUrl});
1229+
_routeProvider.when(prefix + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: routeSpec.templateUrl}, additional));
12231230
});
12241231
// This next bit is just for the demo website to allow demonstrating multiple frameworks - not available with other routers
12251232
if (config.variantsForDemoWebsite) {
12261233
angular.forEach(config.variantsForDemoWebsite, function(variant) {
12271234
angular.forEach(routes, function (routeSpec) {
1228-
_routeProvider.when(config.prefix + variant + routeSpec.route, routeSpec.options || {templateUrl: routeSpec.templateUrl});
1235+
_routeProvider.when(prefix + variant + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: routeSpec.templateUrl}, additional));
12291236
});
12301237
});
12311238
}
12321239
}
12331240

1234-
function _setUpUIRoutes(routes) {
1241+
function _setUpUIRoutes(routes, prefix, additional) {
1242+
prefix = prefix || '';
12351243
angular.forEach(routes, function (routeSpec) {
1236-
_stateProvider.state(routeSpec.state, routeSpec.options || {
1237-
url: routeSpec.route,
1244+
_stateProvider.state(routeSpec.state, angular.extend(routeSpec.options || {
1245+
url: prefix + routeSpec.route,
12381246
templateUrl: routeSpec.templateUrl
1239-
});
1247+
}, additional)
1248+
);
12401249
});
12411250
}
12421251

@@ -1259,6 +1268,18 @@ formsAngular.provider('routingService', [ '$injector', '$locationProvider', func
12591268
}
12601269

12611270
return {
1271+
/*
1272+
options:
1273+
prefix: A string (such as '/db') that gets prepended to all the generated routes. This can be used to
1274+
prevent generated routes (which have a lot of parameters) from clashing with other routes in
1275+
the web app that have nothing to do with CRUD forms
1276+
add2fngRoutes: An object to add to the generated routes. One user case would be to add {authenticate: true}
1277+
so that the client authenticates for certain routes
1278+
html5Mode: boolean
1279+
routing: Must be 'ngroute' or 'uirouter'
1280+
1281+
1282+
*/
12621283
start: function (options) {
12631284
angular.extend(config, options);
12641285
if (config.prefix[0] && config.prefix[0] !== '/') { config.prefix = '/' + config.prefix; }
@@ -1270,13 +1291,13 @@ formsAngular.provider('routingService', [ '$injector', '$locationProvider', func
12701291
case 'ngroute' :
12711292
_routeProvider = $injector.get('$routeProvider');
12721293
if (config.fixedRoutes) { _setUpNgRoutes(config.fixedRoutes); }
1273-
_setUpNgRoutes(builtInRoutes);
1294+
_setUpNgRoutes(builtInRoutes, config.prefix, options.add2fngRoutes);
12741295
break;
12751296
case 'uirouter' :
12761297
_stateProvider = $injector.get('$stateProvider');
12771298
if (config.fixedRoutes) { _setUpUIRoutes(config.fixedRoutes); }
12781299
setTimeout(function () {
1279-
_setUpUIRoutes(builtInRoutes);
1300+
_setUpUIRoutes(builtInRoutes, config.prefix, options.add2fngRoutes);
12801301
});
12811302
break;
12821303
}
@@ -2316,31 +2337,65 @@ formsAngular.factory('pluginHelper', ['formMarkupHelper',function (formMarkupHel
23162337

23172338
exports.extractFromAttr = function (attr, directiveName) {
23182339
var info = {};
2340+
var options = {formStyle: attr.formstyle};
23192341
var directiveOptions = {};
23202342
var directiveNameLength = directiveName.length;
23212343
for (var prop in attr) {
23222344
if (attr.hasOwnProperty(prop)) {
23232345
if (prop.slice(0, 6) === 'fngFld') {
2324-
info[prop.slice(6).toLowerCase()] = attr[prop].replace(/&quot;/g,'"');
2346+
info[prop.slice(6).toLowerCase()] = attr[prop].replace(/&quot;/g, '"');
2347+
} else if (prop.slice(0, 6) === 'fngOpt') {
2348+
options[prop.slice(6).toLowerCase()] = attr[prop].replace(/&quot;/g,'"');
23252349
} else if (prop.slice(0,directiveNameLength) === directiveName) {
23262350
directiveOptions[prop.slice(directiveNameLength).toLowerCase()] = attr[prop].replace(/&quot;/g,'"');
23272351
}
23282352
}
23292353
}
2330-
var options = {formStyle: attr.formstyle};
23312354
return {info: info, options: options, directiveOptions: directiveOptions};
23322355
};
23332356

23342357
exports.buildInputMarkup = function (scope, model, info, options, addButtons, needsX, generateInputControl) {
23352358
var fieldChrome = formMarkupHelper.fieldChrome(scope, info, options,' id="cg_' + info.id + '"');
23362359
var controlDivClasses = formMarkupHelper.controlDivClasses(options);
23372360
var elementHtml = fieldChrome.template + formMarkupHelper.label(scope, info, addButtons, options);
2338-
var buildingBlocks;
2361+
var modelString, idString, nameString;
2362+
23392363
if (addButtons) {
2340-
buildingBlocks = formMarkupHelper.allInputsVars(scope, info, options, 'arrayItem' + (needsX ? '.x' : ''), info.id + '_{{$index}}', info.name + '_{{$index}}');
2364+
modelString = 'arrayItem' + (needsX ? '.x' : '');
2365+
idString = info.id + '_{{$index}}';
2366+
nameString =info.name + '_{{$index}}';
23412367
} else {
2342-
buildingBlocks = formMarkupHelper.allInputsVars(scope, info, options, model + '.' + info.name, info.id, info.name);
2368+
modelString = model + '.' + info.name;
2369+
idString = info.id;
2370+
nameString =info.name;
23432371
}
2372+
2373+
if (options.subschema && info.name.indexOf('.') !== -1) {
2374+
// Schema handling - need to massage the ngModel and the id
2375+
var modelBase = model + '.';
2376+
var compoundName = info.name;
2377+
var root = options.subschemaroot;
2378+
var lastPart = compoundName.slice(root.length+1);
2379+
modelString = modelBase;
2380+
2381+
if (options.index) {
2382+
modelString += root + '[' + options.index + '].' + lastPart;
2383+
idString = 'f_' + modelString.slice(modelBase.length).replace(/(\.|\[|\]\.)/g, '-');
2384+
} else {
2385+
modelString += root;
2386+
if (options.subkey) {
2387+
idString = modelString.slice(modelBase.length).replace(/\./g, '-')+'-subkey'+options.subkeyno + '-' + lastPart;
2388+
modelString += '[' + '$_arrayOffset_' + root.replace(/\./g, '_') + '_' + options.subkeyno + '].' + lastPart;
2389+
} else {
2390+
modelString += '[$index].' + lastPart;
2391+
idString = null;
2392+
nameString = compoundName.replace(/\./g, '-');
2393+
}
2394+
}
2395+
}
2396+
2397+
var buildingBlocks = formMarkupHelper.allInputsVars(scope, info, options, modelString, idString, nameString);
2398+
23442399
elementHtml += formMarkupHelper['handle' + (addButtons ? 'Array' : '') + 'InputAndControlDiv'](
23452400
formMarkupHelper.inputChrome(
23462401
generateInputControl(buildingBlocks),

dist/forms-angular.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/directives/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ formsAngular
502502
}
503503
for (prop in options) {
504504
if (options.hasOwnProperty(prop) && prop[0] !== '$') {
505-
newElement += ' fng-opt-' + prop + '="' + options[prop].toString().replace(/"/g,'&quot;') + '"'; break;
505+
newElement += ' fng-opt-' + prop + '="' + options[prop].toString().replace(/"/g,'&quot;') + '"';
506506
}
507507
}
508508

0 commit comments

Comments
 (0)