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
1
Issues
1
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
Roque
erp5
Commits
b6b986a0
Commit
b6b986a0
authored
May 09, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: refactoring in action pages
parent
ee2cfb59
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
100 deletions
+85
-100
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.js
...teItem/web_page_module/gadget_officejs_common_utils_js.js
+3
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.xml
...eItem/web_page_module/gadget_officejs_common_utils_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.js
...eb_page_module/gadget_officejs_page_action_officejs_js.js
+58
-68
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.xml
...b_page_module/gadget_officejs_page_action_officejs_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
.../web_page_module/gadget_officejs_page_handle_action_js.js
+18
-24
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
...web_page_module/gadget_officejs_page_handle_action_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.js
View file @
b6b986a0
...
...
@@ -26,6 +26,7 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
createDocument
"
,
function
(
options
)
{
var
gadget
=
this
,
doc
=
{
...
...
@@ -113,8 +114,8 @@
form_definition
.
_links
.
action_object_new_content_action
=
{
page
:
"
handle_action
"
,
title
:
"
New Post
"
,
action
:
"
new
"
,
reference
:
"
new
"
,
action
:
"
new
_html_post
"
,
reference
:
"
new
_html_post
"
,
action_type
:
"
object_jio_js_script
"
,
parent_portal_type
:
"
Post Module
"
,
portal_type
:
"
HTML Post
"
,
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.xml
View file @
b6b986a0
...
...
@@ -269,7 +269,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.39
168.2243.39099
</string>
</value>
<value>
<string>
975.39
669.47531.23961
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>
15574
26063.79
</float>
<float>
15574
36424.93
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.js
View file @
b6b986a0
...
...
@@ -55,30 +55,32 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
getActionSettings
"
,
function
(
action_doc
,
portal_type
)
{
var
gadget
=
this
,
page
=
"
handle_action
"
,
action_settings
=
{};
if
(
view_categories
.
includes
(
action_doc
.
action_type
))
{
page
=
"
ojs_controller
"
;
.
declareMethod
(
"
getHTMLElements
"
,
function
(
element_list
)
{
var
gadget
=
this
,
i
=
0
,
element_info_list
=
[],
url_for_parameter_list
=
[],
element_info
;
for
(
var
key
in
element_list
)
{
if
(
element_list
.
hasOwnProperty
(
key
))
{
element_info
=
element_list
[
key
];
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
element_info
});
element_info_list
[
i
]
=
{
reference
:
element_info
.
reference
,
title
:
element_info
.
title
};
i
+=
1
;
}
action_settings
=
{
page
:
page
,
title
:
action_doc
.
title
,
action
:
action_doc
.
reference
,
reference
:
action_doc
.
reference
,
action_type
:
action_doc
.
action_type
,
parent_portal_type
:
portal_type
,
portal_type
:
portal_type
};
//TODO find a better way to handle "add" actions (how to get child portal type?)
//'parent' and 'child' portal_types will be in the custom code of action gadgets
if
(
action_doc
.
reference
===
"
new
"
)
{
return
gadget
.
getSetting
(
'
portal_type
'
)
.
push
(
function
(
child_portal_type
)
{
action_settings
.
portal_type
=
child_portal_type
;
return
action_settings
;
});
}
return
action_settings
;
return
gadget
.
getUrlForList
(
url_for_parameter_list
)
.
push
(
function
(
url_list
)
{
var
html_element_list
=
[],
i
,
element
;
for
(
i
=
0
;
i
<
url_list
.
length
;
i
+=
1
)
{
element
=
{
href
:
url_list
[
i
],
icon
:
null
,
name
:
element_info_list
[
i
].
reference
,
title
:
element_info_list
[
i
].
title
};
html_element_list
.
push
(
element
);
}
return
html_element_list
;
});
})
.
declareMethod
(
"
getAllActions
"
,
function
(
portal_type
,
action_category
)
{
...
...
@@ -96,15 +98,31 @@
return
RSVP
.
all
(
path_for_jio_get_list
);
})
.
push
(
function
(
action_document_list
)
{
var
get_
action_settings_list
=
[],
page
,
action_key
,
action_doc
;
var
action_settings_list
=
[],
page
,
action_key
,
action_doc
;
for
(
action_key
in
action_document_list
)
{
if
(
action_document_list
.
hasOwnProperty
(
action_key
))
{
get_action_settings_list
.
push
(
gadget
.
getActionSettings
(
action_document_list
[
action_key
],
portal_type
));
action_doc
=
action_document_list
[
action_key
];
page
=
"
handle_action
"
;
if
(
view_categories
.
includes
(
action_doc
.
action_type
))
{
page
=
"
ojs_controller
"
;
}
//TODO (how to get child portal type?)
//'parent' and 'child' portal_types will be in the custom code of action gadgets
var
child_portal_type
=
portal_type
;
if
(
action_doc
.
reference
===
"
new_html_post
"
)
{
child_portal_type
=
"
HTML Post
"
;
}
action_settings_list
.
push
({
page
:
page
,
title
:
action_doc
.
title
,
action
:
action_doc
.
reference
,
reference
:
action_doc
.
reference
,
action_type
:
action_doc
.
action_type
,
parent_portal_type
:
portal_type
,
portal_type
:
child_portal_type
});
}
}
return
RSVP
.
all
(
get_action_settings_list
);
})
.
push
(
function
(
action_settings_list
)
{
for
(
var
key
in
action_settings_list
)
{
if
(
action_settings_list
.
hasOwnProperty
(
key
))
{
var
action_settings
=
action_settings_list
[
key
];
...
...
@@ -127,57 +145,29 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
url_for_parameter_list
=
[],
action_info_list
=
[],
action_info_dict
=
{},
document_title
;
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
document
)
{
document_title
=
document
.
title
;
return
gadget
.
getAllActions
(
document
.
portal_type
,
view_categories
[
0
])
;
return
document
.
portal_type
;
},
function
(
error
)
{
document_title
=
options
.
portal_type
;
return
gadget
.
getAllActions
(
options
.
portal_type
,
view_categories
[
0
])
;
return
options
.
portal_type
;
})
.
push
(
function
(
all_actions
)
{
var
action_info
,
i
=
0
;
action_info_dict
=
all_actions
;
//TODO refactor this (actions and views)
for
(
var
action_key
in
action_info_dict
.
actions
)
{
if
(
action_info_dict
.
actions
.
hasOwnProperty
(
action_key
))
{
action_info
=
action_info_dict
.
actions
[
action_key
];
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
action_info
});
action_info_list
[
i
]
=
{
reference
:
action_info
.
reference
,
title
:
action_info
.
title
};
i
+=
1
;
}
}
for
(
var
view_key
in
action_info_dict
.
views
)
{
if
(
action_info_dict
.
views
.
hasOwnProperty
(
view_key
))
{
action_info
=
action_info_dict
.
views
[
view_key
];
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
action_info
});
action_info_list
[
i
]
=
{
reference
:
action_info
.
reference
,
title
:
action_info
.
title
};
i
+=
1
;
}
}
return
gadget
.
getUrlForList
(
url_for_parameter_list
);
.
push
(
function
(
portal_type
)
{
return
gadget
.
getAllActions
(
portal_type
,
view_categories
[
0
]);
})
.
push
(
function
(
action_info_dict
)
{
return
RSVP
.
all
([
gadget
.
getHTMLElements
(
action_info_dict
.
views
),
gadget
.
getHTMLElements
(
action_info_dict
.
actions
)
]);
})
.
push
(
function
(
url_list
)
{
var
action_list
=
[],
view_list
=
[],
i
,
element
;
for
(
i
=
0
;
i
<
url_list
.
length
;
i
+=
1
)
{
element
=
{
href
:
url_list
[
i
],
icon
:
null
,
name
:
action_info_list
[
i
].
reference
,
title
:
action_info_list
[
i
].
title
};
if
(
action_info_dict
.
views
.
hasOwnProperty
(
element
.
name
))
{
view_list
.
push
(
element
);
}
else
{
action_list
.
push
(
element
);
}
}
// TODO: check other lists like clone or delete?
.
push
(
function
(
all_html_elements
)
{
return
RSVP
.
all
([
renderLinkList
(
gadget
,
"
Views
"
,
"
eye
"
,
view_list
),
renderLinkList
(
gadget
,
"
Actions
"
,
"
gear
"
,
a
ction_list
)
renderLinkList
(
gadget
,
"
Views
"
,
"
eye
"
,
all_html_elements
[
0
]
),
renderLinkList
(
gadget
,
"
Actions
"
,
"
gear
"
,
a
ll_html_elements
[
1
]
)
]);
})
.
push
(
function
(
translated_html_link_list
)
{
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.xml
View file @
b6b986a0
...
...
@@ -228,7 +228,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.3
8143.43945.1706
</string>
</value>
<value>
<string>
975.3
9646.60719.8601
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>
1557
344637.28
</float>
<float>
1557
436194.5
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
View file @
b6b986a0
...
...
@@ -60,7 +60,7 @@
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
action_reference
,
valid_action
;
var
gadget
=
this
,
action_reference
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
...
...
@@ -78,14 +78,24 @@
return
gadget
.
getActionFormDefinition
(
action_reference
);
})
.
push
(
function
(
form_definition
)
{
valid_action
=
form_definition
.
action_type
===
"
object_jio_js_script
"
&&
form_definition
.
fields_raw_properties
.
hasOwnProperty
(
"
gadget_field_action_js_script
"
);
var
fragment
=
document
.
createElement
(
'
div
'
),
action_gadget_url
=
form_definition
.
fields_raw_properties
.
gadget_field_action_js_script
.
values
.
gadget_url
,
action_gadget_url
,
form_info
=
getFormInfo
(
form_definition
),
form_type
=
form_info
[
0
],
child_gadget_url
=
form_info
[
1
];
child_gadget_url
=
form_info
[
1
],
valid_action
=
form_definition
.
action_type
===
"
object_jio_js_script
"
&&
form_definition
.
fields_raw_properties
.
hasOwnProperty
(
"
gadget_field_action_js_script
"
),
state_options
=
{
doc
:
{},
parent_options
:
options
,
child_gadget_url
:
child_gadget_url
,
form_type
:
form_type
,
form_definition
:
form_definition
,
view
:
action_reference
,
valid_action
:
valid_action
};
if
(
valid_action
)
{
action_gadget_url
=
form_definition
.
fields_raw_properties
.
gadget_field_action_js_script
.
values
.
gadget_url
;
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
action_gadget_url
,
{
scope
:
"
action_field
"
,
...
...
@@ -95,27 +105,11 @@
return
action_gadget
.
preRenderDocument
(
options
);
})
.
push
(
function
(
doc
)
{
return
gadget
.
changeState
({
doc
:
doc
,
parent_options
:
options
,
child_gadget_url
:
child_gadget_url
,
form_type
:
form_type
,
form_definition
:
form_definition
,
view
:
action_reference
,
valid_action
:
valid_action
});
state_options
.
doc
=
doc
;
return
gadget
.
changeState
(
state_options
);
});
}
else
{
//TODO refactor this to avoid 2 calls almost identical
return
gadget
.
changeState
({
doc
:
{},
parent_options
:
options
,
child_gadget_url
:
child_gadget_url
,
form_type
:
form_type
,
form_definition
:
form_definition
,
view
:
action_reference
,
valid_action
:
valid_action
});
return
gadget
.
changeState
(
state_options
);
}
});
})
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
View file @
b6b986a0
...
...
@@ -269,7 +269,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.39
483.32712.34679
</string>
</value>
<value>
<string>
975.39
668.29926.39628
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>
15574
25011.91
</float>
<float>
15574
36203.22
</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