Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
e9e17215
Commit
e9e17215
authored
5 years ago
by
S.Listl
Browse files
Options
Downloads
Patches
Plain Diff
ViewTemplateData_lib
parent
dce203a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/ViewTemplateData_lib/process.js
+46
-8
46 additions, 8 deletions
process/ViewTemplateData_lib/process.js
with
46 additions
and
8 deletions
process/ViewTemplateData_lib/process.js
+
46
−
8
View file @
e9e17215
/**
* Object to make the creation of a JSON for the Dynamic Form component simpler
* Object to make the creation of a JSON for the Dynamic Form component simpler.
*
* @example
*
* var form = new DynamicFormDefinition()
* .addField("title", "Title", null, null, true)
* .addField("productcode", "Product code")
* .addField("purchasedate", "Purchase date", "DATE")
* .addField("amount", "Amount", "NUMBER", 1);
*
* if (!vars.get("$field.DESCRIPTION"))
* form.addField("description", "Description", "LONG_TEXT");
*
* result.string(form.toString()); //.toString() would also be called implicitly so it could be omitted
*
* @param {String} [pFormDefinition] an already existing form JSON as string
*/
...
...
@@ -12,7 +25,16 @@ function DynamicFormDefinition (pFormDefinition)
this
.
fields
=
[];
}
DynamicFormDefinition
.
prototype
.
addField
=
function
(
pId
,
pName
,
pContentType
,
pMandatory
,
pReadOnly
,
pIsReadable
)
/**
* @param {String} pId unique ID of the field
* @param {String} pName title of the field
* @param {String} [pContentType] content type
* @param {String} [pValue] preset value
* @param {boolean} [pMandatory=false] mandatory
* @param {boolean} [pReadOnly=false] readOnly
* @param {boolean} [pIsReadable=true] readable
*/
DynamicFormDefinition
.
prototype
.
addField
=
function
(
pId
,
pName
,
pContentType
,
pValue
,
pMandatory
,
pReadOnly
,
pIsReadable
)
{
//TODO: check if id is unique
this
.
fields
.
push
({
...
...
@@ -21,24 +43,40 @@ DynamicFormDefinition.prototype.addField = function (pId, pName, pContentType, p
contentType
:
pContentType
||
"
TEXT
"
,
isReadable
:
pIsReadable
||
true
,
isWritable
:
!
pReadOnly
,
isRequired
:
pMandatory
||
false
isRequired
:
pMandatory
||
false
,
value
:
pValue
===
undefined
?
null
:
pValue
});
return
this
;
}
/**
*
*/
DynamicFormDefinition
.
prototype
.
removeField
=
function
(
pId
)
{
var
index
=
this
.
indexOfField
(
pId
);
if
(
index
!=
-
1
)
this
.
fields
.
splice
(
index
,
1
);
return
this
;
}
/**
*
*/
DynamicFormDefinition
.
prototype
.
indexOfField
=
function
(
pId
)
{
for
(
let
i
=
0
,
l
=
this
.
fields
.
length
;
i
<
l
;
i
++
)
{
if
(
this
.
fields
[
i
].
id
==
pId
)
{
this
.
fields
.
splice
(
i
,
1
);
return
this
;
}
return
i
;
}
return
this
;
return
-
1
;
}
/**
*
*/
DynamicFormDefinition
.
prototype
.
toString
=
function
()
{
return
JSON
.
stringify
(
this
.
fields
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment