Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 79f11e8

Browse files
author
Nick Litwin
committed
Refactor stockart section and add validation and error message for inputs with urls
1 parent 0200f24 commit 79f11e8

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

app/submissions/submit-file/submit-file.controller.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// the onChange callback does not indicate which dropdown called the callback.
1313
// There are pull requets pending for react-select which will clean this code up
1414
vm.fontList1 = [
15-
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARDS_FONTS_LIST', id: 1 },
15+
{ label: 'Studio Standard Fonts List', value: 'STUDIO_STANDARD_FONTS_LIST', id: 1 },
1616
{ label: 'Fonts.com', value: 'FONTS_DOT_COM', id: 1 },
1717
{ label: 'MyFonts', value: 'MYFONTS', id: 1 },
1818
{ label: 'Adobe Fonts', value: 'ADOBE_FONTS', id: 1 },
@@ -23,11 +23,10 @@
2323
];
2424

2525
var files = {};
26+
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
2627
vm.comments = '';
2728
vm.submissionForm = {
2829
files: [],
29-
30-
// Should the rank input field be set to 1 automatically?
3130
submitterRank: 1,
3231
submitterComments: '',
3332
fonts: [{

app/submissions/submit-file/submit-file.jade

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
.form-block__fields
8989
.fieldsets
90-
ng-form.fieldset(name="font_{{$index + 1}}", ng-repeat="font in vm.submissionForm.fonts track by font.id")
90+
ng-form.fieldset(name="font{{$index + 1}}", ng-repeat="font in vm.submissionForm.fonts track by font.id")
9191
dropdown(
9292
name="'font-source{{$index + 1}}'",
9393
options="vm.fontList{{$index + 1}}",
@@ -121,23 +121,30 @@
121121

122122
.form-block__fields
123123
.fieldsets
124-
ng-form.fieldset(name="stockArt_{{$index + 1}}", ng-repeat="stockArt in vm.submissionForm.stockArts track by stockArt.id")
124+
.fieldset(ng-repeat="stockArt in vm.submissionForm.stockArts track by stockArt.id")
125125
tc-input.fieldset__input(
126126
label-text="Photo Description",
127127
placeholder="A picture of a girl",
128-
input-value="stockArt.description"
128+
input-value="stockArt.description",
129+
input-name="photoDescription{{$index}}"
129130
)
130131

131132
tc-input.fieldset__input(
132133
label-text="Photo URL",
133134
placeholder="www.istockphoto.com",
134-
input-value="stockArt.sourceUrl"
135+
input-value="stockArt.sourceUrl",
136+
input-name="photoURL{{$index}}",
137+
input-pattern="vm.urlRegEx"
135138
)
136139

140+
.tc-error-messages(ng-show="submissionForm['photoURL' + $index].$dirty && submissionForm['photoURL' + $index].$invalid")
141+
p(ng-show="submissionForm['photoURL' + $index].$error.pattern") Not a valid url.
142+
137143
tc-input.fieldset__input(
138144
label-text="File Number",
139145
placeholder="u2434312",
140-
input-value="stockArt.fileNumber"
146+
input-value="stockArt.fileNumber",
147+
input-name="fileNumber{{$index}}"
141148
)
142149

143150
button.fieldset__button.tc-btn.tc-btn-s(type="button", ng-click="vm.createAnotherStockArtFieldset()") + Add Stock Photo

0 commit comments

Comments
 (0)