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
Amer
erp5
Commits
a5397a63
Commit
a5397a63
authored
5 years ago
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: code refactoring and cleanup
parent
133113b3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
134 deletions
+122
-134
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
...e_module/gadget_officejs_controller_page_controller_js.js
+69
-71
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_page_action_offline_js.js
...web_page_module/gadget_officejs_page_action_offline_js.js
+16
-15
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.xml
...eb_page_module/gadget_officejs_page_action_offline_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
+31
-42
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_controller_page_controller_js.js
View file @
a5397a63
/*global document, window, rJS, RSVP
, URLSearchParams
*/
/*global document, window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
document
,
window
,
rJS
,
RSVP
,
URLSearchParams
)
{
(
function
(
document
,
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
var
default_view
=
"
jio_view
"
;
function
renderField
(
field_id
,
field_definition
,
document
)
{
var
key
,
raw_value
,
tales_expr
,
override
,
final_value
,
result
=
{};
for
(
key
in
field_definition
.
values
)
{
...
...
@@ -155,25 +153,25 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
,
document
,
action_reference
;
jio_document
;
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
jio_documen
t
)
{
document
=
jio_documen
t
;
if
(
document
.
portal_type
===
undefined
)
{
.
push
(
function
(
resul
t
)
{
jio_document
=
resul
t
;
if
(
jio_
document
.
portal_type
===
undefined
)
{
throw
new
Error
(
'
Can not display document:
'
+
options
.
jio_key
);
}
return
gadget
.
getFormDefinition
(
document
.
portal_type
,
options
.
view
)
return
gadget
.
getFormDefinition
(
jio_
document
.
portal_type
,
options
.
view
)
.
push
(
function
(
form_definition
)
{
return
gadget
.
changeState
({
jio_key
:
options
.
jio_key
,
doc
:
document
,
doc
:
jio_
document
,
child_gadget_url
:
child_gadget_url
,
form_definition
:
form_definition
,
editable
:
options
.
editable
,
view
:
options
.
view
,
//HARDCODED: following fields should be indicated by the configuration
has_more_views
:
false
,
has_more_actions
:
options
.
view
==
"
view
"
,
has_more_actions
:
options
.
view
==
=
"
view
"
,
is_form_list
:
false
});
});
...
...
@@ -201,67 +199,67 @@
form_json
:
form_json
})
// render the header
.
push
(
function
()
{
var
url_for_parameter_list
=
[
{
command
:
'
change
'
,
options
:
{
page
:
"
tab
"
}},
{
command
:
'
change
'
,
options
:
{
page
:
"
action_offline
"
}},
{
command
:
'
history_previous
'
},
{
command
:
'
selection_previous
'
},
{
command
:
'
selection_next
'
},
{
command
:
'
change
'
,
options
:
{
page
:
"
export
"
}},
{
command
:
'
display
'
,
options
:
{}}
];
erp5_document
=
form_json
.
erp5_document
;
if
(
erp5_document
.
_links
&&
erp5_document
.
_links
.
action_object_new_content_action
)
{
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
erp5_document
.
_links
.
action_object_new_content_action
});
}
return
RSVP
.
all
([
gadget
.
getUrlForList
(
url_for_parameter_list
),
gadget
.
isDesktopMedia
(),
gadget
.
getSetting
(
'
document_title_plural
'
),
gadget
.
getSetting
(
'
upload_dict
'
,
false
)
]);
})
.
push
(
function
(
result_list
)
{
var
url_list
=
result_list
[
0
],
header_dict
;
if
(
gadget
.
state
.
is_form_list
)
{
header_dict
=
{
panel_action
:
true
,
jump_url
:
""
,
fast_input_url
:
""
,
front_url
:
url_list
[
6
],
filter_action
:
true
,
page_title
:
result_list
[
2
]
};
}
else
{
header_dict
=
{
selection_url
:
url_list
[
2
],
previous_url
:
url_list
[
3
],
next_url
:
url_list
[
4
],
page_title
:
gadget
.
state
.
doc
.
title
};
if
(
gadget
.
state
.
has_more_views
)
{
header_dict
.
tab_url
=
url_list
[
0
];
.
push
(
function
()
{
var
url_for_parameter_list
=
[
{
command
:
'
change
'
,
options
:
{
page
:
"
tab
"
}},
{
command
:
'
change
'
,
options
:
{
page
:
"
action_offline
"
}},
{
command
:
'
history_previous
'
},
{
command
:
'
selection_previous
'
},
{
command
:
'
selection_next
'
},
{
command
:
'
change
'
,
options
:
{
page
:
"
export
"
}},
{
command
:
'
display
'
,
options
:
{}}
];
erp5_document
=
form_json
.
erp5_document
;
if
(
erp5_document
.
_links
&&
erp5_document
.
_links
.
action_object_new_content_action
)
{
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
erp5_document
.
_links
.
action_object_new_content_action
});
}
return
RSVP
.
all
([
gadget
.
getUrlForList
(
url_for_parameter_list
),
gadget
.
isDesktopMedia
(),
gadget
.
getSetting
(
'
document_title_plural
'
),
gadget
.
getSetting
(
'
upload_dict
'
,
false
)
]);
})
.
push
(
function
(
result_list
)
{
var
url_list
=
result_list
[
0
],
header_dict
;
if
(
gadget
.
state
.
is_form_list
)
{
header_dict
=
{
panel_action
:
true
,
jump_url
:
""
,
fast_input_url
:
""
,
front_url
:
url_list
[
6
],
filter_action
:
true
,
page_title
:
result_list
[
2
]
};
}
else
{
header_dict
=
{
selection_url
:
url_list
[
2
],
previous_url
:
url_list
[
3
],
next_url
:
url_list
[
4
],
page_title
:
gadget
.
state
.
doc
.
title
};
if
(
gadget
.
state
.
has_more_views
)
{
header_dict
.
tab_url
=
url_list
[
0
];
}
if
(
gadget
.
state
.
editable
===
"
true
"
)
{
header_dict
.
save_action
=
true
;
}
}
if
(
gadget
.
state
.
editable
===
"
true
"
)
{
header_dict
.
save_action
=
true
;
if
(
gadget
.
state
.
has_more_actions
)
{
header_dict
.
actions_url
=
url_list
[
1
]
;
}
}
if
(
gadget
.
state
.
has_more_actions
)
{
header_dict
.
actions_url
=
url_list
[
1
];
}
if
(
url_list
[
7
])
{
header_dict
.
add_url
=
url_list
[
7
];
}
if
(
result_list
[
1
])
{
header_dict
.
export_url
=
(
erp5_document
.
_links
.
action_object_jio_report
||
erp5_document
.
_links
.
action_object_jio_exchange
||
erp5_document
.
_links
.
action_object_jio_print
)
?
url_list
[
5
]
:
''
;
}
return
gadget
.
updateHeader
(
header_dict
);
});
if
(
url_list
[
7
])
{
header_dict
.
add_url
=
url_list
[
7
];
}
if
(
result_list
[
1
])
{
header_dict
.
export_url
=
(
erp5_document
.
_links
.
action_object_jio_report
||
erp5_document
.
_links
.
action_object_jio_exchange
||
erp5_document
.
_links
.
action_object_jio_print
)
?
url_list
[
5
]
:
''
;
}
return
gadget
.
updateHeader
(
header_dict
);
});
})
.
onStateChange
(
function
()
{
...
...
@@ -281,4 +279,4 @@
});
});
}(
document
,
window
,
rJS
,
RSVP
,
URLSearchParams
));
\ No newline at end of file
}(
document
,
window
,
rJS
,
RSVP
));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
View file @
a5397a63
...
...
@@ -225,7 +225,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.
59024.11735.30037
</string>
</value>
<value>
<string>
974.
60126.24569.41489
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>
1554
751815.26
</float>
<float>
1554
817831.18
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.js
View file @
a5397a63
/*global window, rJS, RSVP, Handlebars
, UriTemplate, calculatePageTitle, ensureArray
*/
/*global window, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
UriTemplate
,
calculatePageTitle
,
ensureArray
)
{
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
)
{
"
use strict
"
;
/////////////////////////////////////////////////////////////////
...
...
@@ -55,7 +55,6 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
action_info_list
=
[],
erp5_document
,
document_title
;
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
document
)
{
...
...
@@ -75,29 +74,31 @@
})
.
push
(
function
(
action_document_list
)
{
var
url_for_parameter_list
=
[],
i
=
0
,
page
,
action_key
,
action_doc
;
page
,
action_key
,
action_doc
;
for
(
action_key
in
action_document_list
)
{
page
=
"
handle_action
"
;
action_doc
=
action_document_list
[
action_key
];
if
(
action_doc
.
reference
==
"
view
"
||
action_doc
.
reference
==
"
jio_view
"
)
{
page
=
"
ojs_controller
"
;
if
(
action_document_list
.
hasOwnProperty
(
action_key
))
{
page
=
"
handle_action
"
;
action_doc
=
action_document_list
[
action_key
];
if
(
action_doc
.
reference
===
"
view
"
||
action_doc
.
reference
===
"
jio_view
"
)
{
page
=
"
ojs_controller
"
;
}
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
{
page
:
page
,
action
:
action_doc
.
reference
}});
action_info_list
[
i
]
=
{
reference
:
action_doc
.
reference
,
title
:
action_doc
.
title
};
i
+=
1
;
}
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
{
page
:
page
,
action
:
action_doc
.
reference
}});
action_info_list
[
i
]
=
{
reference
:
action_doc
.
reference
,
title
:
action_doc
.
title
};
i
+=
1
;
}
return
gadget
.
getUrlForList
(
url_for_parameter_list
);
})
.
push
(
function
(
url_list
)
{
var
action_list
=
[],
view_list
=
[],
url
,
i
,
element
;
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
};
// TODO: maybe both view and jio_view should be ignored here
if
(
element
.
name
!=
"
view
"
)
{
if
(
element
.
name
==
"
jio_view
"
)
{
if
(
element
.
name
!=
=
"
view
"
)
{
if
(
element
.
name
==
=
"
jio_view
"
)
{
view_list
.
push
(
element
);
}
else
{
action_list
.
push
(
element
);
...
...
@@ -125,4 +126,4 @@
return
;
});
}(
window
,
rJS
,
RSVP
,
Handlebars
,
UriTemplate
,
calculatePageTitle
,
ensureArray
));
\ No newline at end of file
}(
window
,
rJS
,
RSVP
,
Handlebars
));
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.xml
View file @
a5397a63
...
...
@@ -228,7 +228,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.
58836.59077.24849
</string>
</value>
<value>
<string>
974.
60153.5925.35891
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>
1554
740463.74
</float>
<float>
1554
819442.65
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
View file @
a5397a63
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
Blob
)
{
(
function
(
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
rJS
(
window
)
...
...
@@ -19,52 +19,41 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
handleAction
"
,
function
(
jio_key
,
portal_type
)
{
var
gadget
=
this
,
jio_document
,
action_reference
;
.
declareMethod
(
"
handleAction
"
,
function
(
jio_key
)
{
var
gadget
=
this
,
action_reference
;
return
gadget
.
getUrlParameter
(
"
action
"
)
.
push
(
function
(
action_parameter
)
{
action_reference
=
action_parameter
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
document
)
{
// This is the custom code to handle this specific reply action
if
(
action_reference
==
"
reply
"
)
{
var
doc
,
title
=
document
.
title
;
if
(
!
title
.
startsWith
(
"
Re:
"
))
{
title
=
"
Re:
"
+
document
.
title
;
.
push
(
function
(
action_parameter
)
{
action_reference
=
action_parameter
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
document
)
{
// This is the custom code to handle this specific reply action
if
(
action_reference
==
"
reply
"
)
{
var
doc
,
title
=
document
.
title
;
if
(
!
title
.
startsWith
(
"
Re:
"
))
{
title
=
"
Re:
"
+
document
.
title
;
}
doc
=
{
title
:
title
,
//thread parent: same as base post
source_reference
:
document
.
source_reference
,
portal_type
:
document
.
portal_type
,
parent_relative_url
:
document
.
parent_relative_url
};
return
gadget
.
jio_post
(
doc
)
.
push
(
function
(
id
)
{
return
[
id
,
action_reference
];
});
}
doc
=
{
title
:
title
,
//thread parent: same as base post
source_reference
:
document
.
source_reference
,
portal_type
:
document
.
portal_type
,
parent_relative_url
:
document
.
parent_relative_url
};
return
gadget
.
jio_post
(
doc
)
.
push
(
function
(
id
)
{
jio_key
=
id
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
created_doc
)
{
jio_document
=
created_doc
;
return
[
jio_key
,
jio_document
,
action_reference
];
});
}
return
[
jio_key
,
jio_document
,
action_reference
];
});
return
[
jio_key
,
action_reference
];
});
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
doc_id
;
var
gadget
=
this
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getSetting
(
'
portal_type
'
),
gadget
.
getSetting
(
'
parent_relative_url
'
)
]);
})
.
push
(
function
(
result
)
{
return
gadget
.
handleAction
(
options
.
jio_key
,
result
[
0
]);
return
gadget
.
handleAction
(
options
.
jio_key
);
})
.
push
(
function
(
action_result
)
{
return
gadget
.
redirect
({
...
...
@@ -72,9 +61,9 @@
options
:
{
page
:
undefined
,
jio_key
:
action_result
[
0
],
view
:
action_result
[
2
]
view
:
action_result
[
1
]
}
});
});
});
}(
window
,
rJS
,
RSVP
,
Blob
));
}(
window
,
rJS
,
RSVP
));
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
View file @
a5397a63
...
...
@@ -269,7 +269,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.
59012.7910.14933
</string>
</value>
<value>
<string>
974.
60145.32757.53879
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>
1554
751292.19
</float>
<float>
1554
818976.22
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
This diff is collapsed.
Click to expand it.
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