Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoji Takeuchi
erp5
Commits
30ec359f
Commit
30ec359f
authored
Feb 05, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: moving json-form render method to a main gadget (controller for now)
parent
97b5c80f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
121 deletions
+129
-121
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
...e_module/gadget_officejs_controller_page_controller_js.js
+103
-29
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
..._module/gadget_officejs_controller_page_controller_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_html_post_view_js.js
.../web_page_module/gadget_officejs_jio_html_post_view_js.js
+22
-88
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_html_post_view_js.xml
...web_page_module/gadget_officejs_jio_html_post_view_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
View file @
30ec359f
...
...
@@ -15,6 +15,73 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
getFormDefinition
"
,
function
()
{
//somehow the form_definition should come from the erp5-doc/form (jio?)
//for now, hardcoded form_definition for POST VIEW
return
{
_debug
:
"
traverse
"
,
pt
:
"
form_view
"
,
title
:
"
Post
"
,
group_list
:
[[
"
left
"
,
[[
"
my_title
"
,
{
meta_type
:
"
StringField
"
}]]
],
[
"
bottom
"
,
[[
"
my_text_content
"
,
{
meta_type
:
"
ProxyField
"
}]]
]],
//this field_info is totally made up, but somewhere in the definition there must be
//information about the fields. So, foreach field: key->info
field_info_dict
:
{
"
my_title
"
:
{
"
title
"
:
"
Title
"
,
"
default
"
:
"
Undefined title
"
,
"
editable
"
:
1
,
"
key
"
:
"
title
"
,
"
type
"
:
"
StringField
"
},
"
my_text_content
"
:
{
"
editable
"
:
1
,
"
key
"
:
"
text_content
"
,
"
renderjs_extra
"
:
'
{"editor": "fck_editor",
'
+
'
"maximize": true}
'
,
"
type
"
:
"
GadgetField
"
,
"
url
"
:
"
gadget_editor.html
"
,
"
sandbox
"
:
"
public
"
}
},
action
:
"
Base_edit
"
,
update_action
:
""
,
_links
:
{}
};
})
.
declareMethod
(
"
generateJsonRenderForm
"
,
function
(
form_definition
,
document
)
{
var
form_json
=
{
erp5_document
:
{
"
_embedded
"
:
{
"
_view
"
:
{}},
"
_links
"
:
{}
},
form_definition
:
form_definition
};
for
(
var
i
=
0
;
i
<
form_definition
.
group_list
.
length
;
i
++
)
{
var
fields
=
form_definition
.
group_list
[
i
][
1
];
for
(
var
j
=
0
;
j
<
fields
.
length
;
j
++
)
{
var
my_element
=
fields
[
j
][
0
],
element_id
;
if
(
my_element
.
startsWith
(
"
my_
"
))
{
element_id
=
my_element
.
replace
(
"
my_
"
,
""
);
}
var
field_info
=
form_definition
.
field_info_dict
[
my_element
];
if
(
document
&&
document
.
hasOwnProperty
(
element_id
))
{
field_info
[
"
default
"
]
=
document
[
element_id
];
}
form_json
.
erp5_document
.
_embedded
.
_view
[
my_element
]
=
field_info
;
form_json
.
erp5_document
.
_links
=
form_definition
.
_links
;
}
}
return
form_json
;
})
.
allowPublicAcquisition
(
'
notifySubmit
'
,
function
()
{
return
this
.
triggerSubmit
();
})
...
...
@@ -41,10 +108,8 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
child_gadget_url
;
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
result
)
{
if
(
result
.
portal_type
!==
undefined
)
{
child_gadget_url
=
'
gadget_officejs_jio_
'
+
result
.
portal_type
.
replace
(
/ /g
,
'
_
'
).
toLowerCase
()
+
...
...
@@ -52,38 +117,47 @@
}
else
{
throw
new
Error
(
'
Can not display document:
'
+
options
.
jio_key
);
}
//somehow the form_definition should come from the erp5-doc/form (jio?)
return
gadget
.
getFormDefinition
(
options
.
jio_key
)
.
push
(
function
(
form_definition
)
{
return
gadget
.
changeState
({
jio_key
:
options
.
jio_key
,
doc
:
result
,
child_gadget_url
:
child_gadget_url
child_gadget_url
:
child_gadget_url
,
form_definition
:
form_definition
});
});
});
})
.
onStateChange
(
function
(
modification_dict
)
{
var
fragment
=
document
.
createElement
(
'
div
'
),
gadget
=
this
;
return
gadget
.
generateJsonRenderForm
(
gadget
.
state
.
form_definition
,
gadget
.
state
.
doc
)
.
push
(
function
(
form_json
)
{
if
(
!
modification_dict
.
hasOwnProperty
(
'
child_gadget_url
'
))
{
return
gadget
.
getDeclaredGadget
(
'
fg
'
)
.
push
(
function
(
child_gadget
)
{
return
child_gadget
.
render
({
jio_key
:
gadget
.
state
.
jio_key
,
doc
:
gadget
.
state
.
doc
doc
:
gadget
.
state
.
doc
,
form_json
:
form_json
});
});
}
// Clear first to DOM, append after to reduce flickering/manip
while
(
this
.
element
.
firstChild
)
{
this
.
element
.
removeChild
(
this
.
element
.
firstChild
);
while
(
gadget
.
element
.
firstChild
)
{
gadget
.
element
.
removeChild
(
gadget
.
element
.
firstChild
);
}
this
.
element
.
appendChild
(
fragment
);
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
gadget
.
state
.
child_gadget_url
,
{
element
:
fragment
,
scope
:
'
fg
'
})
.
push
(
function
(
form_gadget
)
{
return
form_gadget
.
render
({
jio_key
:
gadget
.
state
.
jio_key
,
doc
:
gadget
.
state
.
doc
doc
:
gadget
.
state
.
doc
,
form_json
:
form_json
});
});
});
});
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
View file @
30ec359f
...
...
@@ -227,7 +227,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
67.6016.61211.59613
</string>
</value>
<value>
<string>
9
73.30677.12698.50312
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>
15
24754712.5
1
</float>
<float>
15
49379093.0
1
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_html_post_view_js.js
View file @
30ec359f
...
...
@@ -18,72 +18,11 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
generateJsonRenderForm
"
,
function
(
gadget
)
{
//hardcoded form_definition (this should come from erp5 form)
var
form_definition
=
{
_debug
:
"
traverse
"
,
pt
:
"
form_view
"
,
title
:
"
Post
"
,
group_list
:
[[
"
left
"
,
[[
"
my_title
"
,
{
meta_type
:
"
StringField
"
}]]
],
[
"
bottom
"
,
[[
"
my_text_content
"
,
{
meta_type
:
"
ProxyField
"
}]]
]],
//this field_info is totally made up, but somewhere in the definition there must be
//information about the fields. So, foreach field: key->info
field_info_dict
:
{
"
my_title
"
:
{
"
title
"
:
"
Title
"
,
"
default
"
:
"
Undefined title
"
,
"
editable
"
:
1
,
"
key
"
:
"
title
"
,
"
type
"
:
"
StringField
"
},
"
my_text_content
"
:
{
"
editable
"
:
1
,
"
key
"
:
"
text_content
"
,
"
renderjs_extra
"
:
'
{"editor": "fck_editor",
'
+
'
"maximize": true}
'
,
"
type
"
:
"
GadgetField
"
,
"
url
"
:
"
gadget_editor.html
"
,
"
sandbox
"
:
"
public
"
}
},
action
:
"
Base_edit
"
,
update_action
:
""
,
_links
:
{}
},
form_json
=
{
erp5_document
:
{
"
_embedded
"
:
{
"
_view
"
:
{}},
"
_links
"
:
{}
},
form_definition
:
form_definition
};
for
(
var
i
=
0
;
i
<
form_definition
.
group_list
.
length
;
i
++
)
{
var
fields
=
form_definition
.
group_list
[
i
][
1
];
for
(
var
j
=
0
;
j
<
fields
.
length
;
j
++
)
{
var
my_element
=
fields
[
j
][
0
],
element_id
;
if
(
my_element
.
startsWith
(
"
my_
"
))
{
element_id
=
my_element
.
replace
(
"
my_
"
,
""
);
}
var
field_info
=
form_definition
.
field_info_dict
[
my_element
];
if
(
gadget
.
state
.
hasOwnProperty
(
"
doc
"
)
&&
gadget
.
state
.
doc
.
hasOwnProperty
(
element_id
))
{
field_info
[
"
default
"
]
=
gadget
.
state
.
doc
[
element_id
];
}
form_json
.
erp5_document
.
_embedded
.
_view
[
my_element
]
=
field_info
;
form_json
.
erp5_document
.
_links
=
form_definition
.
_links
;
}
}
return
form_json
;
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
return
this
.
changeState
({
jio_key
:
options
.
jio_key
,
doc
:
options
.
doc
doc
:
options
.
doc
,
form_json
:
options
.
form_json
});
})
...
...
@@ -109,14 +48,10 @@
})
.
onStateChange
(
function
()
{
var
gadget
=
this
,
form_json
;
return
gadget
.
generateJsonRenderForm
(
gadget
)
.
push
(
function
(
result
)
{
form_json
=
result
;
var
gadget
=
this
;
return
gadget
.
getDeclaredGadget
(
'
form_view
'
)
.
push
(
function
(
form_gadget
)
{
return
form_gadget
.
render
(
form_json
);
return
form_gadget
.
render
(
gadget
.
state
.
form_json
);
})
.
push
(
function
()
{
return
RSVP
.
all
([
...
...
@@ -135,5 +70,4 @@
});
});
});
});
}(
window
,
rJS
,
RSVP
));
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_html_post_view_js.xml
View file @
30ec359f
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
973.
29142.36243.7697
</string>
</value>
<value>
<string>
973.
30699.43343.35106
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>
1549
285941.45
</float>
<float>
1549
379311.18
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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