Skip to content

Commit b6e16b2

Browse files
committed
solve bugs and webConstructor
1 parent dd229dd commit b6e16b2

File tree

12 files changed

+82
-53
lines changed

12 files changed

+82
-53
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ Carthage/Checkouts
2222
*.framework.dSYM*
2323
Carthage/Build/Mac
2424
Carthage/Build/tvOS
25-
Carthage/Build/watchOS
25+
Carthage/Build/watchOS
26+
/WebFormulary/HTML5Application/nbproject/private/
27+
/WebFormulary/nbproject/private/

Application/Json/json_formulary.json

+15-42
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
11
{
22
"fields":[
33
{
4-
"key": "a",
4+
"key": "a1",
55
"type": "text",
6-
"label": "soy un titulo",
7-
"mandatory": true,
8-
"textError": "errrrror",
9-
"placeHolder": "mete algo aqui",
10-
"keyboard": "FormKeyboardTypeEmail",
11-
"validator": "custom",
12-
"customRegex": "^([0-9])+$",
13-
"style": {
14-
"backgroundColorField": "#648cff",
15-
"titleColor": "#94ff9a",
16-
"errorColor": "#ff4a4c",
17-
"sizeTitle": 30,
18-
"sizeError": 22,
19-
"align": "alignCenter",
20-
"font": "AppleSDGothicNeo-SemiBold"
21-
}
6+
"label": "validador sin",
7+
"mandatory": true
228
},
239
{
24-
"key": "cc",
25-
"type": "boolean",
26-
"label": "elige o no",
27-
"textError": "error"
10+
"key": "a2",
11+
"type": "text",
12+
"label": "validador email",
13+
"validator": "email",
14+
"mandatory": true
2815
},
2916
{
30-
"key": "bb",
31-
"type": "picker",
32-
"label": "titul picker",
33-
"listOptions": [
34-
{
35-
"key": "KeyNoSelected",
36-
"value": "por defecto"
37-
},
38-
{
39-
"key": "a",
40-
"value": "opcion 1"
41-
},
42-
{
43-
"key": "b",
44-
"value": "opcion 2"
45-
}
46-
],
47-
"mandatory": true,
48-
"textError": "error texto picker",
49-
"textAcceptButton": "acepta"
17+
"key": "a3",
18+
"type": "text",
19+
"label": "validador custom",
20+
"validator": "customValidator",
21+
"customValidator": "^([0-9])+$",
22+
"mandatory": true
5023
}
51-
]
24+
]
5225
}

GIGFormulary/Source/Builder/FormBuilderFields.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class FormBuilderFields: NSObject {
7676
guard
7777
let validate = formFieldM.validator,
7878
let typeValidate = TypeValidator(rawValue: validate)
79-
else { return Validator(mandatory: formFieldM.mandatory) }
79+
else {
80+
return Validator(mandatory: formFieldM.mandatory)
81+
}
8082

8183
let typeValidator = self.validatorsType[typeValidate]
8284
let validator: Validator

GIGFormulary/Source/FormConstant.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ enum TypeValidator: String {
3333
case VALIDATOR_BOOL = "bool"
3434
case VALIDATOR_DNINIE = "dniNie"
3535
case VALIDATOR_AGE = "age"
36-
case VALIDATOR_CUSTOM = "custom"
36+
case VALIDATOR_CUSTOM = "customValidator"
3737
}
3838

3939
enum ThrowError: Error {

GIGFormulary/Source/Model/FormFieldModel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class FormFieldModel: NSObject {
6565
let minAge = json["minAge"] as? Int
6666
let textAcceptButton = json["textAcceptButton"] as? String
6767
let value = json["value"]
68-
let custom = json["customRegex"] as? String
68+
let custom = json["customValidator"] as? String
6969

7070

7171
//== INSERT DATA ==

WebFormulary/aux/auxText.html

+3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
<option value="postalCode">Código postal</option>
4242
<option value="phone">Teléfono</option>
4343
<option value="dniNie">DNI/NIE</option>
44+
<option value="customValidator">Custom</option>
4445
</select>
46+
<input id="custonValidator" placeHolder="Regex Custom">
4547
</div>
4648
<div class="errorTextField">
4749
<p class="textErrorP">Texto error:</p>
@@ -99,6 +101,7 @@ <h4>Estilos de celda:</h4>
99101
<p>Es obligatorio?</p>
100102
</div>
101103
<div class="validatorResult">Validator:'+validator+'</div>
104+
102105
</div>
103106
<div class="errorTextField">
104107
<p class="textErrorP">Texto error:</p>

WebFormulary/css/style.css

+12-1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
float: left;
368368
margin-left: 16px;
369369
margin-top: 22px;
370+
margin-right: 20px;
370371
}
371372

372373
.keyboardResult{
@@ -634,8 +635,18 @@
634635
margin-left: 31px;
635636
}
636637

638+
#custonValidator {
639+
position: relative;
640+
top: 9px;
641+
width: 100px;
642+
margin-top: 0px;
643+
display: none;
644+
}
637645

638-
646+
#customValidatorTextField{
647+
width: 200px;
648+
margin: 13px 0 0 17px;
649+
}
639650

640651

641652

WebFormulary/js/jsWeb.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createElementField(typeField) {
6666
var htmlImage = getHtmlImageMandatory();
6767

6868
if (typeField == "Text") {
69-
html = ' <div class="cellConstructor" id="createField"> <div class="row"> <div class="col-md-10"> <div class="keyTextField"> <p>key*:</p><input type="text" name="keyTextField" id="keyTextField"> </div><div class="containerTextFieldTop"> <div class="titleTextField"> <p>Titulo*:</p><input type="text" name="titleTextField" id="titleTextField"> </div><select id="selectTypeKeyboard"> <option value="None">Elegir tipo de teclado</option> <option value="FormKeyboardTypeText">Texto</option> <option value="FormKeyboardTypeEmail">Email</option> <option value="FormKeyboardTypeNumbers">Nuerico</option> <option value="FormKeyboardTypeNumberPad">NuericoPad</option> </select> </div><div class="containerTextFieldCenter"> <div class="inputTextField"> <p>PlaceHolder:</p><input type="text" name="palceHolderTextField" id="palceHolderTextField"> </div><div class="mandatoryTextField"> <input type="checkbox" name="mandatory" value="mandatory" id="mandatory"> <p>Es obligatorio?</p></div><select id="selectTypeValidator"> <option value="None">Tipo validador</option> <option value="text">Texto</option> <option value="email">Email</option> <option value="lengthText">Long texto</option> <option value="numeric">Numérico</option> <option value="postalCode">Código postal</option> <option value="phone">Teléfono</option> <option value="dniNie">DNI/NIE</option> </select> </div><div class="errorTextField"> <p class="textErrorP">Texto error:</p><input type="text" name="errorTextField"id="errorTextField"> <p>minLength:</p><input class="inputWidth" type="text" name="minLength"id="minLength"> <p>maxLength:</p><input class="inputWidth" type="text" name="maxLength"id="maxLength"> </div><div class="styleField"> <h4>Estilos de celda:</h4> <div class="colorZone"> '+colorBasicZone+' </div><div class="sizeZone"> <p>Tamaño titulo:</p><input id="sizeTitle" type="text" name="element"> <p>Tamaño texto error:</p><input id="sizeError" type="text" name="element"> </div>'+htmlFont+htmlImage+' </div><div class="spaceSeparate"></div></div><div class="col-md-2 buttonAdd" onclick="addField()"> <p>+</p></div></div></div>';
69+
html = ' <div class="cellConstructor" id="createField"> <div class="row"> <div class="col-md-10"> <div class="keyTextField"> <p>key*:</p><input type="text" name="keyTextField" id="keyTextField"> </div><div class="containerTextFieldTop"> <div class="titleTextField"> <p>Titulo*:</p><input type="text" name="titleTextField" id="titleTextField"> </div><select id="selectTypeKeyboard"> <option value="None">Elegir tipo de teclado</option> <option value="FormKeyboardTypeText">Texto</option> <option value="FormKeyboardTypeEmail">Email</option> <option value="FormKeyboardTypeNumbers">Nuerico</option> <option value="FormKeyboardTypeNumberPad">NuericoPad</option> </select> </div><div class="containerTextFieldCenter"> <div class="inputTextField"> <p>PlaceHolder:</p><input type="text" name="palceHolderTextField" id="palceHolderTextField"> </div><div class="mandatoryTextField"> <input type="checkbox" name="mandatory" value="mandatory" id="mandatory"> <p>Es obligatorio?</p></div><select id="selectTypeValidator"> <option value="None">Tipo validador</option> <option value="text">Texto</option> <option value="email">Email</option> <option value="lengthText">Long texto</option> <option value="numeric">Numérico</option> <option value="postalCode">Código postal</option> <option value="phone">Teléfono</option> <option value="customValidator">Custom</option> </select> <input id="custonValidator" placeHolder="Regex Custom"> </div><div class="errorTextField"> <p class="textErrorP">Texto error:</p><input type="text" name="errorTextField"id="errorTextField"> <p>minLength:</p><input class="inputWidth" type="text" name="minLength"id="minLength"> <p>maxLength:</p><input class="inputWidth" type="text" name="maxLength"id="maxLength"> </div><div class="styleField"> <h4>Estilos de celda:</h4> <div class="colorZone"> '+colorBasicZone+' </div><div class="sizeZone"> <p>Tamaño titulo:</p><input id="sizeTitle" type="text" name="element"> <p>Tamaño texto error:</p><input id="sizeError" type="text" name="element"> </div>'+htmlFont+htmlImage+' </div><div class="spaceSeparate"></div></div><div class="col-md-2 buttonAdd" onclick="addField()"> <p>+</p></div></div></div>';
7070

7171
}
7272
else if (typeField == "Picker") {
@@ -88,6 +88,7 @@ function createElementField(typeField) {
8888

8989
launchEventColors();
9090
createEventFont();
91+
showContainerCustomValidate();
9192
}
9293

9394
function createEventFont() {
@@ -101,6 +102,17 @@ function createEventFont() {
101102
});
102103
}
103104

105+
function showContainerCustomValidate() {
106+
$("#selectTypeValidator").change(function() {
107+
if (this.value == "customValidator") {
108+
$("#custonValidator").css("display","block");
109+
}
110+
else {
111+
$("#custonValidator").css("display","none");
112+
}
113+
});
114+
}
115+
104116
function syntaxHighlight(json) {
105117
if (typeof json != 'string') {
106118
json = JSON.stringify(json, undefined, 2);

WebFormulary/js/textField.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// TEXT //
44
//======================================
55

6-
function createField(keyTextField,title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory) {
6+
function createField(keyTextField,title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory,customValidator) {
77
var valueCheck = ""
88
if (mandatory) {
99
valueCheck = "checked"
@@ -17,13 +17,18 @@ function createField(keyTextField,title,placeHolder,error,mandatory,cellColor,ke
1717

1818
var styles = htmlFontSize + htmlBackgroundColor + htmlAlingFont + htmlImages;
1919

20-
var html = '<div class="cellConstructor"id="fieldNumber'+indexField+'"><div class="row"><div class="col-md-10"><div class="keyTextField"><p>key*:</p><input type="text"name="keyTextField"id="keyTextField"disabled value="'+keyTextField+'"></div><div class="containerTextFieldTop"><div class="titleTextField"><p>Titulo*:</p><input type="text"name="titleTextField"id="titleTextField"disabled value="'+title+'"></div><div class="keyboardResult">Keyboard:'+keyboard+'</div></div><div class="containerTextFieldCenter"><div class="inputTextField"><p>PlaceHolder:</p><input type="text"name="palceHolderTextField"id="palceHolderTextField"disabled value="'+placeHolder+'"></div><div class="mandatoryTextField"><input type="checkbox"name="mandatory"value="mandatory"id="mandatory"'+valueCheck+' disabled readonly><p>Es obligatorio?</p></div><div class="validatorResult">Validator:'+validator+'</div></div><div class="errorTextField"><p class="textErrorP">Texto error:</p><input type="text"name="errorTextField"id="errorTextField"disabled value="'+error+'"><p>minLength:</p><input class="inputWidth"type="text"name="minLength"id="minLength"disabled readonly value="'+minLength+'"><p>maxLength:</p><input class="inputWidth"type="text"name="maxLength"id="maxLength"disabled readonly value="'+maxLength+'"></div><div class="styleField"><h4>Estilos de celda:</h4>'+styles+'</div><div class="spaceSeparate"></div></div><div class="col-md-2 buttonRemove buttonRemoveText"onclick="removeField('+indexField+')"><p>-</p></div></div></div>';
20+
$htmlCustomValidator = ""
21+
if (validator == "customValidator") {
22+
$htmlCustomValidator = '<input type="text"name="customValidatorTextField"id="customValidatorTextField"disabled value="'+customValidator+'">'
23+
}
24+
25+
var html = '<div class="cellConstructor"id="fieldNumber'+indexField+'"><div class="row"><div class="col-md-10"><div class="keyTextField"><p>key*:</p><input type="text"name="keyTextField"id="keyTextField"disabled value="'+keyTextField+'"></div><div class="containerTextFieldTop"><div class="titleTextField"><p>Titulo*:</p><input type="text"name="titleTextField"id="titleTextField"disabled value="'+title+'"></div><div class="keyboardResult">Keyboard:'+keyboard+'</div></div><div class="containerTextFieldCenter"><div class="inputTextField"><p>PlaceHolder:</p><input type="text"name="palceHolderTextField"id="palceHolderTextField"disabled value="'+placeHolder+'"></div><div class="mandatoryTextField"><input type="checkbox"name="mandatory"value="mandatory"id="mandatory"'+valueCheck+' disabled readonly><p>Es obligatorio?</p></div><div class="validatorResult">Validator:'+validator+'</div> '+$htmlCustomValidator+' </div><div class="errorTextField"><p class="textErrorP">Texto error:</p><input type="text"name="errorTextField"id="errorTextField"disabled value="'+error+'"><p>minLength:</p><input class="inputWidth"type="text"name="minLength"id="minLength"disabled readonly value="'+minLength+'"><p>maxLength:</p><input class="inputWidth"type="text"name="maxLength"id="maxLength"disabled readonly value="'+maxLength+'"></div><div class="styleField"><h4>Estilos de celda:</h4>'+styles+'</div><div class="spaceSeparate"></div></div><div class="col-md-2 buttonRemove buttonRemoveText"onclick="removeField('+indexField+')"><p>-</p></div></div></div>';
2126

2227
$("#containerListItemsCreated").append(html);
2328
resetTypeField();
2429
}
2530

26-
function saveField(keyTextField,type,title,placeHolder,textError,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory) {
31+
function saveField(keyTextField,type,title,placeHolder,textError,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory,customValidator) {
2732
//-- Mandatory Fiedls --
2833
var itemSave = {
2934
"tag":indexField,
@@ -52,8 +57,12 @@ function saveField(keyTextField,type,title,placeHolder,textError,mandatory,cellC
5257
}
5358
if (validator != "None") {
5459
itemSave["validator"] = validator
60+
if (validator == "customValidator") {
61+
itemSave["customValidator"] = customValidator
62+
}
5563
}
5664

65+
5766
//-- OPTIONAL FIELDS --
5867
var styles = getStylesJson(cellColor,titleColor,errorColor,sizeTitle,sizeError,"","","",align,font,imageMandatory,"","");
5968

WebFormulary/js/validations.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ function validateTextField() {
4444
var align = document.getElementById("selectTypeAlign").value;
4545
var font = document.getElementById("selectTypeFont").value;
4646
var imageMandatory = $("#imageMandatory").val()
47+
var custonValidator = $("#custonValidator").val()
4748

4849
if (font == "custom") {
4950
font = $("#custonFont").val()
5051
}
5152

5253
if (controlError(title,keyTextField,font,sizeTitle,sizeError)) {
53-
createField(keyTextField,title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory);
54-
saveField(keyTextField,"text",title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory)
54+
createField(keyTextField,title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory,custonValidator);
55+
saveField(keyTextField,"text",title,placeHolder,error,mandatory,cellColor,keyboard,validator,minLength,maxLength,titleColor,errorColor,sizeTitle,sizeError,align,font,imageMandatory,custonValidator)
5556
}
5657
}
5758

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include.path=${php.global.include.path}
2+
php.version=PHP_56
3+
source.encoding=UTF-8
4+
src.dir=.
5+
tags.asp=false
6+
tags.short=false
7+
web.root=.

WebFormulary/nbproject/project.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.php.project</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/php-project/1">
6+
<name>WebFormulary</name>
7+
</data>
8+
</configuration>
9+
</project>

0 commit comments

Comments
 (0)