This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Example now includes number, integer & email fields #4
Open
olimart
wants to merge
1
commit into
launchscout:master
Choose a base branch
from
olimart:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="form-group" ng-class="{'has-error': formState[field].$invalid}"> | ||
<label for="{{field}}" class="control-label">{{schema.title}}</label> | ||
<input id="{{field}}" ng-attr-name="{{field}}" ng-model="model[field]" type="email" class="form-control"></input> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": { | ||
"lib": { | ||
"includeVendorInDistribution": false, | ||
"generateBowerJson": true | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,28 @@ | |
editAs: "@" | ||
}, | ||
link: function(scope, element, attrs, formController) { | ||
var template; | ||
var template, typeTemplates; | ||
typeTemplates = { | ||
bool: 'boolean', | ||
boolean: 'boolean', | ||
email: 'email', | ||
"enum": 'enum', | ||
integer: 'string', | ||
number: 'string', | ||
string: 'string' | ||
}; | ||
scope.formState = formController; | ||
template = scope.schema["enum"] != null ? $templateCache.get("enumField.html") : $templateCache.get("" + scope.schema.type + "Field.html"); | ||
template = $templateCache.get("" + typeTemplates[scope.schema.type] + "Field.html"); | ||
if (scope.schema["enum"] != null) { | ||
template = $templateCache.get("enumField.html"); | ||
} | ||
element.html(template); | ||
if (scope.schema.type === "number" || scope.schema.type === "integer") { | ||
element.find("input").attr("type", "number"); | ||
} | ||
if (scope.schema.type === "email") { | ||
element.find("input").attr("type", "email"); | ||
} | ||
element.find("input").attr("ng-required", scope.required); | ||
if (scope.schema.pattern) { | ||
element.find("input").attr("ng-pattern", "/" + scope.schema.pattern + "/"); | ||
|
@@ -59,37 +74,3 @@ | |
}); | ||
|
||
}).call(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the intent here is to have dist be the bower component. That's why the templates are compiled into this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bear with me I'm not super confident here. I did 2 things:
Both do the same things, however I could not get the example working without emailField template. Maybe I'm missing something though. |
||
|
||
angular.module("schemaForm").run(["$templateCache", function($templateCache) { | ||
|
||
$templateCache.put("booleanField.html", | ||
"<div class=\"form-group\">\n" + | ||
" <label for=\"{{field}}\">{{schema.title}}</label>\n" + | ||
" <input id=\"{{field}}\" name=\"field\" ng-model=\"model[field]\" type=\"checkbox\"></input>\n" + | ||
"</div>\n" | ||
); | ||
|
||
$templateCache.put("enumField.html", | ||
"<div class=\"form-group\">\n" + | ||
" <label for=\"{{field}}\">{{schema.title}}</label>\n" + | ||
" <select id=\"{{field}}\" name=\"{{field}}\" ng-model=\"model[field]\" ng-options=\"enumValue for enumValue in schema.enum\"></select>\n" + | ||
"</div>\n" | ||
); | ||
|
||
$templateCache.put("schemaFormFields.html", | ||
"<div ng-repeat=\"field in fields\">\n" + | ||
" <schema-form-field field=\"field\"\n" + | ||
" schema=\"schema.properties[field]\"\n" + | ||
" model=\"model\" required=\"required(field)\">\n" + | ||
" </schema-form-field>\n" + | ||
"</div>\n" | ||
); | ||
|
||
$templateCache.put("stringField.html", | ||
"<div class=\"form-group\" ng-class=\"{'has-error': formState[field].$invalid}\">\n" + | ||
" <label for=\"{{field}}\" class=\"control-label\">{{schema.title}}</label>\n" + | ||
" <input id=\"{{field}}\" ng-attr-name=\"{{field}}\" ng-model=\"model[field]\" type=\"text\" class=\"form-control\"></input>\n" + | ||
"</div>\n" | ||
); | ||
|
||
}]); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning for wanting to take out ngtemplates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took it out because lineman was complaining "uncompressedDist" (see config/lib.json to config/application.json). Else it was throwing an error. But I have to admit, I have no idea what it does.
I wasn't sure if you added it or if lineman generates it. In brand new lineman app, there is no mention of this.