add required in editorFactory
add required in editorFactory
This commit is contained in:
parent
edb85afd67
commit
6eba56d7f8
|
@ -50,14 +50,14 @@ EditorFactory.prototype.createChoice = function(value, defaultValue, name,
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorFactory.prototype.createField = function(label, name, size, id, value) {
|
EditorFactory.prototype.createField = function(label, name, required, size, id, value) {
|
||||||
var div = this.createBaseEditor(label, id);
|
var div = this.createBaseEditor(label, id);
|
||||||
$(div).children(".editor").attr("editorType", "field");
|
$(div).children(".editor").attr("editorType", "field");
|
||||||
$(div).children(".editor").append(this.createFieldLine(size, name, value));
|
$(div).children(".editor").append(this.createFieldLine(size, name, required, value));
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorFactory.prototype.createMultiField = function(label, name, size, id,
|
EditorFactory.prototype.createMultiField = function(label, name, required, size, id,
|
||||||
value) {
|
value) {
|
||||||
var div = this.createBaseEditor(label, id);
|
var div = this.createBaseEditor(label, id);
|
||||||
$(div).children(".editor").attr("editorType", "multiField");
|
$(div).children(".editor").attr("editorType", "multiField");
|
||||||
|
@ -65,7 +65,7 @@ EditorFactory.prototype.createMultiField = function(label, name, size, id,
|
||||||
var values = value.split(";");
|
var values = value.split(";");
|
||||||
for (var i = 0; i < values.length; i++) {
|
for (var i = 0; i < values.length; i++) {
|
||||||
$(div).children(".editor").append(
|
$(div).children(".editor").append(
|
||||||
this.createFieldLine(size, name, values[i]));
|
this.createFieldLine(size, name, required, values[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,19 +94,22 @@ EditorFactory.prototype.createMultiField = function(label, name, size, id,
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorFactory.prototype.createFieldLine = function(size, name, value) {
|
EditorFactory.prototype.createFieldLine = function(size, name, required, value) {
|
||||||
var fieldDiv = document.createElement("div");
|
var fieldDiv = document.createElement("div");
|
||||||
$(fieldDiv).addClass("field");
|
$(fieldDiv).addClass("field");
|
||||||
var fieldName = document.createElement("label");
|
var fieldName = document.createElement("label");
|
||||||
$(fieldName).html(name);
|
$(fieldName).html(name);
|
||||||
var field = document.createElement("input");
|
var field = document.createElement("input");
|
||||||
$(field).attr("type", "text");
|
$(field).attr("type", "text");
|
||||||
|
if(required=="true"){
|
||||||
|
$(field).attr("required", "required");
|
||||||
|
}
|
||||||
// $(field).attr("maxlength", size);
|
// $(field).attr("maxlength", size);
|
||||||
$(field).attr("value", value);
|
$(field).attr("value", value);
|
||||||
$(fieldDiv).append(fieldName.outerHTML + field.outerHTML);
|
$(fieldDiv).append(fieldName.outerHTML + field.outerHTML);
|
||||||
return fieldDiv;
|
return fieldDiv;
|
||||||
}
|
}
|
||||||
EditorFactory.prototype.createFile = function(label, name, size, id, value) {
|
EditorFactory.prototype.createFile = function(label, name, required, size, id, value) {
|
||||||
if (size == null || size <= 0) {
|
if (size == null || size <= 0) {
|
||||||
size = 150;
|
size = 150;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +122,9 @@ EditorFactory.prototype.createFile = function(label, name, size, id, value) {
|
||||||
$(fieldName).html(name);
|
$(fieldName).html(name);
|
||||||
var file = document.createElement("input");
|
var file = document.createElement("input");
|
||||||
$(file).attr("type", "file");
|
$(file).attr("type", "file");
|
||||||
|
if(required == "true"){
|
||||||
|
$(field).attr("required", "required");
|
||||||
|
}
|
||||||
// $(field).attr("maxlength", size);
|
// $(field).attr("maxlength", size);
|
||||||
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
|
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
|
||||||
$(div).children(".editor").append(fileEditor);
|
$(div).children(".editor").append(fileEditor);
|
||||||
|
@ -134,7 +140,7 @@ EditorFactory.prototype.createTable = /**
|
||||||
* @param value
|
* @param value
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function(label, name, cols, id, value) {
|
function(label, name, required, cols, id, value) {
|
||||||
|
|
||||||
var div = this.createBaseEditor(label, id);
|
var div = this.createBaseEditor(label, id);
|
||||||
$(div).children(".editor").attr("editorType", "table");
|
$(div).children(".editor").attr("editorType", "table");
|
||||||
|
@ -152,7 +158,7 @@ function(label, name, cols, id, value) {
|
||||||
function(event) {
|
function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$(this).parent().children("table").children("tbody").append(
|
$(this).parent().children("table").children("tbody").append(
|
||||||
createTr(event.data.headers, event.data.fieldName));
|
createTr(event.data.headers, event.data.fieldName, required));
|
||||||
});
|
});
|
||||||
var deleteButton = document.createElement("button");
|
var deleteButton = document.createElement("button");
|
||||||
$(deleteButton).html("remove");
|
$(deleteButton).html("remove");
|
||||||
|
@ -188,7 +194,7 @@ function(label, name, cols, id, value) {
|
||||||
var tbody = document.createElement("tbody");
|
var tbody = document.createElement("tbody");
|
||||||
$(thead).append(createHeader(headers));
|
$(thead).append(createHeader(headers));
|
||||||
for (var i = 0; i < values.length; i++) {//this minus one because there is a "|;" in the end of value string
|
for (var i = 0; i < values.length; i++) {//this minus one because there is a "|;" in the end of value string
|
||||||
$(tbody).append(createTr(headers, name, values[i]));
|
$(tbody).append(createTr(headers, name, required, values[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(table).append(thead);
|
$(table).append(thead);
|
||||||
|
@ -208,7 +214,7 @@ function(label, name, cols, id, value) {
|
||||||
}
|
}
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
function createTr(headers, name, value) {
|
function createTr(headers, name, required, value) {
|
||||||
value == null? value="":value;
|
value == null? value="":value;
|
||||||
var values = value.split("|");
|
var values = value.split("|");
|
||||||
var tr = document.createElement("tr");
|
var tr = document.createElement("tr");
|
||||||
|
@ -220,6 +226,9 @@ function(label, name, cols, id, value) {
|
||||||
var input = document.createElement("input");
|
var input = document.createElement("input");
|
||||||
$(input).attr("type", "text");
|
$(input).attr("type", "text");
|
||||||
$(input).attr("style","width:"+"90%");
|
$(input).attr("style","width:"+"90%");
|
||||||
|
if(required == "true"){
|
||||||
|
$(field).attr("required", "required");
|
||||||
|
}
|
||||||
if(values[i] != undefined){
|
if(values[i] != undefined){
|
||||||
$(input).val(values[i].split("=")[1]);
|
$(input).val(values[i].split("=")[1]);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +268,7 @@ EditorFactory.prototype.createSelect = function(label, name, size, options, id,
|
||||||
$(div).children(".editor").append(select);
|
$(div).children(".editor").append(select);
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
EditorFactory.prototype.createDate = function(label, name, size, id, value) {
|
EditorFactory.prototype.createDate = function(label, name, required, size, id, value) {
|
||||||
|
|
||||||
if (size == null || size < 0) {
|
if (size == null || size < 0) {
|
||||||
size = 150
|
size = 150
|
||||||
|
@ -270,6 +279,9 @@ EditorFactory.prototype.createDate = function(label, name, size, id, value) {
|
||||||
$(dateLabel).html(name);
|
$(dateLabel).html(name);
|
||||||
var date = document.createElement("input");
|
var date = document.createElement("input");
|
||||||
$(date).attr("type", "date");
|
$(date).attr("type", "date");
|
||||||
|
if(required == "true"){
|
||||||
|
$(field).attr("required", "required");
|
||||||
|
}
|
||||||
$(div).children(".editor").append(dateLabel);
|
$(div).children(".editor").append(dateLabel);
|
||||||
$(div).children(".editor").append(date);
|
$(div).children(".editor").append(date);
|
||||||
return div;
|
return div;
|
||||||
|
|
Loading…
Reference in New Issue