Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_workflow
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenjie.zheng
erp5_workflow
Commits
5065c94d
Commit
5065c94d
authored
May 17, 2012
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ERP5Form rather than more generic Form as it represents an ERP5 form gadget renderer.
parent
17604a77
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
293 additions
and
295 deletions
+293
-295
bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/erp5_form.js.xml
...tem/portal_skins/erp5_xhtml_gadget_style/erp5_form.js.xml
+288
-290
bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadgets/tabular_gadget/gadget.xml
...erp5_xhtml_gadget_style/gadgets/tabular_gadget/gadget.xml
+4
-4
bt5/erp5_xhtml_gadget_style/bt/revision
bt5/erp5_xhtml_gadget_style/bt/revision
+1
-1
No files found.
bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/erp5_form.js.xml
View file @
5065c94d
...
...
@@ -8,7 +8,7 @@
<dictionary>
<item>
<key>
<string>
_EtagSupport__etag
</string>
</key>
<value>
<string>
ts3725
1959.68
</string>
</value>
<value>
<string>
ts3725
6095.54
</string>
</value>
</item>
<item>
<key>
<string>
__name__
</string>
</key>
...
...
@@ -26,23 +26,26 @@
Form field renderer.\n
Note: This is an ERP5 form implementation for the moment.\n
*/\n
var Form = {\n
\n
// elements marked with this class can be serizlized to server\n
SERIALIZE_ABLE_CLASS_NAME: "serialize-able",\n
var ERP5Form = function () {\n
\n
var CURRENT_FORM_ID = "";\n
\n
return {\n
\n
CURRENT_FORM_ID: "",\n
// elements marked with this class can be serialized to server\n
SERIALIZE_ABLE_CLASS_NAME: "serialize-able",\n
\n
getCurrentFormId: function () {\n
/* Get current form ID (return hard coded one for now) */\n
return this.
CURRENT_FORM_ID;\n
return
CURRENT_FORM_ID;\n
},\n
\n
setCurrentFormId: function (form_id) {\n
/* Set current form ID (return hard coded one for now) */\n
this.
CURRENT_FORM_ID = form_id;\n
CURRENT_FORM_ID = form_id;\n
},\n
\n
\n
getFieldId: function(field_id) {\n
/* Generate local form field id */\n
return "field_" + field_id;\n
...
...
@@ -73,7 +76,7 @@ var Form = {\n
}\n
});\n
},\n
\n
\n
BaseInputField: function (field_id, field_dict) {\n
/* HTML based input field */\n
var dom, display_width;\n
...
...
@@ -84,7 +87,7 @@ var Form = {\n
dom.attr("size", display_width);}\n
return dom;\n
},\n
\n
\n
EditorField: function (field_id, field_dict) {\n
/* HTML based input field */\n
var dom;\n
...
...
@@ -92,26 +95,26 @@ var Form = {\n
this.updateField(dom, field_dict);\n
return dom;\n
},\n
\n
\n
ListField: function (field_id, field_dict) {\n
/* Select field */\n
var field_value, select_dom;\n
field_value = field_dict.value;\n
select_dom = $("select[name=" + this.getFieldId(field_id) + "]");\n
this.addOptionTagList(select_dom, field_dict.items, field_value);\n
return select_dom;
\n
return select_dom;
\n
},\n
\n
\n
ParallelListField: function (field_id, field_dict) {\n
/* mutiple select fields */\n
var field_value, select_dom;
\n
var field_value, select_dom;
\n
// XXX: we render only first value but it can be many how to get them ?\n
field_value = field_dict.value[0];\n
select_dom = $("select[name=subfield_field_" + field_id + "]");\n
this.addOptionTagList(select_dom, field_dict.items, field_value);\n
return select_dom;\n
},\n
\n
\n
CheckBoxField: function (field_id, field_dict) {\n
/* CheckBoxField field */\n
var checked, checkbox_dom;\n
...
...
@@ -127,17 +130,17 @@ var Form = {\n
/* TextArea field */\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
\n
StringField: function (field_id, field_dict) {\n
/* String field */\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
\n
IntegerField: function (field_id, field_dict) {\n
/* Int field */\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
\n
PasswordField: function (field_id, field_dict) {\n
/* PasswordField field */\n
return this.BaseInputField(field_id, field_dict);\n
...
...
@@ -153,12 +156,12 @@ var Form = {\n
dom.datepicker(\'setDate\', date);\n
return dom;\n
},\n
\n
\n
EmailField: function (field_id, field_dict) {\n
/* Email field */\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
\n
FormBox: function (field_id, field_dict) {\n
/* Email field */\n
return this.BaseInputField(field_id, field_dict);\n
...
...
@@ -176,15 +179,15 @@ var Form = {\n
// XXX: image field should return details like quality, etc ...\n
dom.attr("src", field_dict.value + "?quality=75.0
&display=thumbnail&format=png");
\n
},\n
\n
\n
ListBox: function (field_id, field_dict) {\n
/* Listbox field */\n
var listbox_id, navigation_id, listbox_table, current_form_id, listbox_dict, listbox_data_url, colModel, column_title_list;\n
listbox_id = "field_" + field_id;\n
navigation_id = listbox_id + "_pager";
\n
navigation_id = listbox_id + "_pager";
\n
listbox_table = $("#"+listbox_id);\n
current_form_id = this.getCurrentFormId();\n
\n
\n
listbox_dict = field_dict.listbox;\n
listbox_data_url = listbox_dict.listbox_data_url;\n
colModel = [];\n
...
...
@@ -219,13 +222,7 @@ var Form = {\n
caption: field_dict.title});\n
listbox_table.jqGrid(\'navGrid\', \'#\'+navigation_id, {edit:false,add:false,del:false});\n
return listbox_table;\n
}\n
\n
};\n
\n
/* Generic form updater */\n
var FormUpdater = {\n
\n
},\n
\n
update: function(data) {\n
/* Update form values */\n
...
...
@@ -234,20 +231,20 @@ var FormUpdater = {\n
var type, dom;\n
type = field_dict.type;\n
dom = undefined;\n
if(
Form.hasOwnProperty(type)){\n
dom =
Form[type](field_id, field_dict);\n
if(ERP5
Form.hasOwnProperty(type)){\n
dom = ERP5
Form[type](field_id, field_dict);\n
}\n
\n
\n
// add a class that these fields are editable so asJSON\n
// can serialize for for sending to server\n
if (dom!==undefined
&&
dom!==null
&&
field_dict.editable){\n
dom.addClass(
Form.SERIALIZE_ABLE_CLASS_NAME);\n
dom.addClass(ERP5
Form.SERIALIZE_ABLE_CLASS_NAME);\n
}\n
\n
\n
// mark required fields visually\n
if (field_dict.required){\n
dom.parent().parent().children("label").css("font-weight", "bold");}\n
\n
\n
});\n
},\n
\n
...
...
@@ -255,10 +252,10 @@ var FormUpdater = {\n
/* save form to server*/\n
var form_value_dict, converted_value;\n
form_value_dict = {};\n
$("." +
Form.SERIALIZE_ABLE_CLASS_NAME).each(function(index){\n
$("." + ERP5
Form.SERIALIZE_ABLE_CLASS_NAME).each(function(index){\n
// DOM can change values, i.e. alter checkbox (on / off)\n
var element,name, value, type;
\n
element = $(this);
\n
var element,name, value, type;
\n
element = $(this);
\n
name = element.attr("name");\n
value = element.val();\n
type = element.attr("type");\n
...
...
@@ -270,16 +267,16 @@ var FormUpdater = {\n
if(value===false) {\n
converted_value=0;\n
}\n
value = converted_value;
\n
value = converted_value;
\n
}\n
// XXX: how to handle file uploads ?\n
form_value_dict[name] = value;\n
});\n
//console.log(form_value_dict);\n
\n
\n
// add form_id as we need to know structure we\'re saving at server side\n
form_value_dict.form_id =
Form.getCurrentFormId();\n
\n
form_value_dict.form_id = ERP5
Form.getCurrentFormId();\n
\n
// validation happens at server side\n
$.ajax({url:\'Form_save\',\n
data: form_value_dict,\n
...
...
@@ -291,7 +288,7 @@ var FormUpdater = {\n
//console.log(field_errors);\n
$.each(field_errors, function(index, value){\n
var dom, field;\n
dom = $("[name=" +
Form.getFieldId(index) + "]");\n
dom = $("[name=" + ERP5
Form.getFieldId(index) + "]");\n
dom.css("border", "1px solid red"); // XXX: use class / css\n
field = dom.parent().parent();\n
if (field.children("span.error").length > 0){\n
...
...
@@ -308,7 +305,7 @@ var FormUpdater = {\n
// delete validation messages\n
var element;\n
element = $(this);\n
element.parent().children("div.input").children("." +
Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.parent().children("div.input").children("." +ERP5
Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.remove();\n
});\n
// show a fading portal_status_message\n
...
...
@@ -318,7 +315,8 @@ var FormUpdater = {\n
}\n
}});\n
}\n
};\n
\n
}} ();\n
]]>
</string>
</value>
...
...
@@ -329,7 +327,7 @@ var FormUpdater = {\n
</item>
<item>
<key>
<string>
size
</string>
</key>
<value>
<int>
1
2313
</int>
</value>
<value>
<int>
1
4114
</int>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
...
...
bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadgets/tabular_gadget/gadget.xml
View file @
5065c94d
...
...
@@ -56,14 +56,14 @@
<div
class=
"document"
>
\n
\n
<div
class=
"actions"
>
\n
<button
onclick=
"javascript:
FormUpdater
.save(); return false;"
\n
<button
onclick=
"javascript:
ERP5Form
.save(); return false;"
\n
title=
"Save"
class=
"save"
type=
"submit"
>
\n
<span
class=
"image"
></span>
\n
<span
class=
"description"
>
Save
</span>
\n
</button>
\n
\n
<script
type=
"text/javascript"
\n
tal:content=
"python: \'\'\'Form.setCurrentFormId(\'%s\');;\'\'\' %current_form_id"
>
\n
tal:content=
"python: \'\'\'
ERP5
Form.setCurrentFormId(\'%s\');;\'\'\' %current_form_id"
>
\n
</script>
\n
\n
<!-- get all tabs from server -->
\n
...
...
@@ -74,7 +74,7 @@
tal:attributes=
"id action_form;\n
class python: action == current_action and \'selected\' or \'not_selected\'"
>
\n
\n
<a
tal:attributes=
"onclick python: \'\'\'javascript: TabbularGadget.addNewTabGadget(\'form_gadget\', \'%s/Form_asRenderJSGadget\', \'
FormUpdater.update\', \'Form_asJSON?form_id=%s\');; TabbularGadget.toggleVisibility($(\'#%s\'));;
Form.setCurrentFormId(\'%s\');;return false ;;\'\'\' %(action_form, action_form, action_form, action_form)"
>
\n
<a
tal:attributes=
"onclick python: \'\'\'javascript: TabbularGadget.addNewTabGadget(\'form_gadget\', \'%s/Form_asRenderJSGadget\', \'
ERP5Form.update\', \'Form_asJSON?form_id=%s\');; TabbularGadget.toggleVisibility($(\'#%s\'));; ERP5
Form.setCurrentFormId(\'%s\');;return false ;;\'\'\' %(action_form, action_form, action_form, action_form)"
>
\n
<span
i18n:translate=
""
\n
i18n:domain=
"ui"
\n
tal:content=
"action/name"
>
action_name
</span>
\n
...
...
@@ -91,7 +91,7 @@
<div
id=
"form_gadget"
\n
tal:attributes=
"gadget string:${current_form_id}/Form_asRenderJSGadget;\n
gadget:data-source string:Form_asJSON?form_id=${current_form_id};\n
gadget:data-handler string:
FormUpdater
.update;\n
gadget:data-handler string:
ERP5Form
.update;\n
gadget:property string: {"cacheable": "1", "cache_id": "${current_form_id}"}"
>
\n
</div>
\n
\n
...
...
bt5/erp5_xhtml_gadget_style/bt/revision
View file @
5065c94d
5
\ No newline at end of file
6
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment