Skip to content

Commit

Permalink
Merge pull request #926 from franciscovn/b4.0.0-beta1
Browse files Browse the repository at this point in the history
Validations and restrictions of csv format form
  • Loading branch information
janosimas authored Mar 6, 2017
2 parents 3a90298 + 190b2b4 commit 61f9a92
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 16 deletions.
7 changes: 6 additions & 1 deletion webapp/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,5 +672,10 @@
"Property name": "Property name",
"Point (Geometry)": "Point (Geometry)",
"Number": "Number",
"Text": "Text"
"Text": "Text",
"Float": "Float",
"Integer": "Integer",
"Required": "Required",
"Invalid format": "Invalid format",
"Invalid alias": "Invalid alias"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ define([],function(){
bindings: {
field: '<',
fieldsType: '<',
onDelete: '&'
onDelete: '&',
semantics: '<'
},
templateUrl: '/dist/templates/data-series/templates/csvFieldDetail.html',
controller: FieldDetailController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define([],function(){
var terrama2CsvFormatComponent = {
bindings: {
csvFormatData: '<',
semantics: '<'
},
templateUrl: '/dist/templates/data-series/templates/csvFormat.html',
controller: CsvFormatController
Expand All @@ -24,15 +25,16 @@ define([],function(){

// Types of fields in csv file
ctrl.fieldsType = [
{title: "Point (Geometry)", value: "GEOMETRY_POINT"},
{title: "Number", value: "FLOAT"},
{title: "Text", value: "TEXT"},
{title: "Date", value: "DATETIME"}
{title: "Point (Geometry)", value: "GEOMETRY_POINT", defaultType: false},
{title: "Float", value: "FLOAT", defaultType: true},
{title: "Integer", value: "INTEGER", defaultType: true},
{title: "Text", value: "TEXT", defaultType: true},
{title: "Date", value: "DATETIME", defaultType: false}
];

// Function to add new format in model
ctrl.addField = function(){
var newFormat = {type: "GEOMETRY_POINT"};
var newFormat = {type: "FLOAT"};
ctrl.csvFormatData.fields.push(newFormat);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Type')+':'"></label>
<select name="type" class="form-control" ng-model="$ctrl.field.type" ng-change="$ctrl.onFieldTypeChange()" required>
<option ng-repeat="type in $ctrl.fieldsType" value="{{type.value}}">{{$ctrl.i18n.__(type.title)}}</option>
<option ng-repeat="type in $ctrl.fieldsType" ng-if="$ctrl.semantics == 'OCCURRENCE' || type.value != 'GEOMETRY_POINT' " value="{{type.value}}">{{$ctrl.i18n.__(type.title)}}</option>
</select>
</div>
</div>
Expand All @@ -14,34 +14,62 @@
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Latitude')+':'"></label>
<input name="latitude" class="form-control" type="text" ng-model="$ctrl.field.latitude_property_name" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.latitude.$dirty && csvFieldsForm.latitude.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Longitude')+':'"></label>
<input name="longitude" class="form-control" type="text" ng-model="$ctrl.field.longitude_property_name" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.longitude.$dirty && csvFieldsForm.longitude.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Alias')+':'"></label>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" required>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" pattern="^[a-zA-Z_][a-zA-Z0-9_]*$" required>
<label class="help-block text-danger"
ng-if="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
<label class="help-block text-danger"
ng-if="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.pattern"
ng-bind="$ctrl.i18n.__('Invalid alias')">
</label>
</div>
</div>
</div>

<div class="col-md-9" ng-if="$ctrl.field.type == 'FLOAT' || $ctrl.field.type == 'TEXT'">
<div class="col-md-9" ng-if="$ctrl.field.type == 'FLOAT' || $ctrl.field.type == 'INTEGER' || $ctrl.field.type == 'TEXT'">
<div class="row">
<div class="col-md-6">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Property name')+':'"></label>
<input name="property_name" class="form-control" type="text" ng-model="$ctrl.field.property_name" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.property_name.$dirty && csvFieldsForm.property_name.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Alias')+':'"></label>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" required>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" pattern="^[a-zA-Z_][a-zA-Z0-9_]*$" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
<label class="help-block text-danger"
ng-if="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.pattern"
ng-bind="$ctrl.i18n.__('Invalid alias')">
</label>
</div>
</div>
</div>
Expand All @@ -52,18 +80,38 @@
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Property name')+':'"></label>
<input name="property_name" class="form-control" type="text" ng-model="$ctrl.field.property_name" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.property_name.$dirty && csvFieldsForm.property_name.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Format')+':'"></label>
<input name="format" class="form-control" type="text" ng-model="$ctrl.field.format" required>
<input name="format" class="form-control" type="text" ng-model="$ctrl.field.format" pattern="^([\w*.]+|%YYYY|%YY|%MM|%DD|%hh|%mm|%ss)+$" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.format.$dirty && csvFieldsForm.format.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
<label class="help-block text-danger"
ng-if="csvFieldsForm.format.$dirty && csvFieldsForm.format.$error.pattern"
ng-bind="$ctrl.i18n.__('Invalid format')">
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Alias')+':'"></label>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" required>
<input name="alias" class="form-control" type="text" ng-model="$ctrl.field.alias" pattern="^[a-zA-Z_][a-zA-Z0-9_]*$" required>
<label class="help-block text-danger"
ng-show="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.required"
ng-bind="$ctrl.i18n.__('Required')">
</label>
<label class="help-block text-danger"
ng-if="csvFieldsForm.alias.$dirty && csvFieldsForm.alias.$error.pattern"
ng-bind="$ctrl.i18n.__('Invalid alias')">
</label>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="form-group" terrama2-show-errors>
<label ng-bind="$ctrl.i18n.__('Default type')+':'"></label>
<select name="default_type" class="form-control" ng-model="$ctrl.csvFormatData.default_type" required>
<option ng-repeat="type in $ctrl.fieldsType" value="{{type.value}}">{{$ctrl.i18n.__(type.title)}}</option>
<option ng-repeat="type in $ctrl.fieldsType" ng-if="type.defaultType" value="{{type.value}}">{{$ctrl.i18n.__(type.title)}}</option>
</select>
</div>
</div>
Expand All @@ -41,7 +41,7 @@
<div class="col-md-12">
<div class="form-group">
<label ng-bind="$ctrl.i18n.__('Fields')+':'"></label>
<csv-field-detail ng-repeat="field in $ctrl.csvFormatData.fields" field="field" fields-type="$ctrl.fieldsType" on-delete="$ctrl.deleteField(field)"></csv-field-detail>
<csv-field-detail ng-repeat="field in $ctrl.csvFormatData.fields" field="field" fields-type="$ctrl.fieldsType" on-delete="$ctrl.deleteField(field)" semantics="$ctrl.semantics"></csv-field-detail>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion webapp/public/javascripts/angular/wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<wz-step wz-title="{{ i18n.__('CSV Format') }}" canexit="validateSteps" wz-disabled="{{!custom_format}}" wz-data="wizard.csvFormat">
<div class="col-md-12">
<form name="forms.csvFormatForm">
<csv-format csv-format-data="csvFormatData"></csv-format>
<csv-format csv-format-data="csvFormatData" semantics="semantics"></csv-format>
</form>
</div>

Expand Down

0 comments on commit 61f9a92

Please sign in to comment.