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
51333e0a
Commit
51333e0a
authored
Jun 19, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: getting views and actions methods are moved to utils
parent
57f15fc6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
100 deletions
+105
-100
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.js
...teItem/web_page_module/gadget_officejs_common_utils_js.js
+92
-3
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
+9
-93
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
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.js
View file @
51333e0a
/*global window, rJS, Query, SimpleQuery, ComplexQuery, console */
/*global window, rJS,
RSVP,
Query, SimpleQuery, ComplexQuery, console */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
Query
,
SimpleQuery
,
ComplexQuery
,
console
)
{
(
function
(
window
,
rJS
,
RSVP
,
Query
,
SimpleQuery
,
ComplexQuery
,
console
)
{
"
use strict
"
;
"
use strict
"
;
// TODO: check if there are other categories that are 'views' and find a less hardcoded way to get this
// TODO: check if there are other categories that are 'views' and find a less hardcoded way to get this
var
view_categories
=
[
"
object_view
"
,
"
object_jio_view
"
,
"
object_web_view
"
,
"
object_list
"
];
var
view_categories
=
[
"
object_view
"
,
"
object_jio_view
"
,
"
object_web_view
"
,
"
object_list
"
];
function
filterViews
(
views_dict
,
app_view
,
default_view
)
{
// there must be only one "View" action (title = "View")
// this is for scenarios were the portal type has several "View" (like view, jio_view, custom_view)
// priority: app_view ; default_view ; other
var
only_view
,
key
,
view_list
=
Object
.
keys
(
views_dict
).
map
(
function
(
key
)
{
if
(
views_dict
[
key
].
title
===
"
View
"
)
{
return
key
;
}
});
if
(
view_list
.
includes
(
app_view
))
{
only_view
=
app_view
;
}
else
if
(
view_list
.
includes
(
default_view
))
{
only_view
=
default_view
;
}
else
{
only_view
=
view_list
[
0
];
}
for
(
key
in
view_list
)
{
if
(
view_list
[
key
]
!==
only_view
)
{
delete
views_dict
[
view_list
[
key
]];
}
}
return
views_dict
;
}
rJS
(
window
)
rJS
(
window
)
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Acquired methods
// Acquired methods
...
@@ -27,6 +50,71 @@
...
@@ -27,6 +50,71 @@
// declared methods
// declared methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
getAllViewsAndActions
"
,
function
(
portal_type
,
jio_key
)
{
var
gadget
=
this
,
action_info_dict
=
{
views
:
{},
actions
:
{}},
//TODO use Query to avoid strings
query
=
'
portal_type: "Action Information" AND parent_relative_url: "portal_types/
'
+
portal_type
+
'
"
'
,
app_actions
,
app_view
,
default_view
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getSetting
(
'
app_view_reference
'
),
gadget
.
getSetting
(
'
default_view_reference
'
)
]);
})
.
push
(
function
(
result_list
)
{
app_view
=
result_list
[
0
];
default_view
=
result_list
[
1
];
return
gadget
.
getAppActions
(
portal_type
);
})
.
push
(
function
(
app_actions_result
)
{
app_actions
=
app_actions_result
.
map
(
function
(
pair
)
{
return
pair
[
1
];
});
return
gadget
.
jio_allDocs
({
query
:
query
})
.
push
(
function
(
action_list
)
{
var
path_for_jio_get_list
=
[],
row
;
for
(
row
in
action_list
.
data
.
rows
)
{
if
(
action_list
.
data
.
rows
.
hasOwnProperty
(
row
))
{
path_for_jio_get_list
.
push
(
gadget
.
jio_get
(
action_list
.
data
.
rows
[
row
].
id
));
}
}
return
RSVP
.
all
(
path_for_jio_get_list
);
})
.
push
(
function
(
action_document_list
)
{
var
page
,
action_key
,
action_doc
,
key
,
action_settings
;
for
(
action_key
in
action_document_list
)
{
if
(
action_document_list
.
hasOwnProperty
(
action_key
))
{
action_doc
=
action_document_list
[
action_key
];
if
(
app_actions
.
includes
(
action_doc
.
reference
))
{
action_settings
=
{
page
:
undefined
,
jio_key
:
jio_key
,
title
:
action_doc
.
title
,
action
:
action_doc
.
reference
,
reference
:
action_doc
.
reference
,
action_type
:
action_doc
.
action_type
,
parent_portal_type
:
portal_type
};
if
(
view_categories
.
includes
(
action_settings
.
action_type
))
{
action_settings
.
page
=
"
ojs_local_controller
"
;
action_info_dict
.
views
[
action_settings
.
action
]
=
action_settings
;
}
else
{
action_settings
.
page
=
"
handle_action
"
;
action_info_dict
.
actions
[
action_settings
.
action
]
=
action_settings
;
}
}
}
}
action_info_dict
.
views
=
filterViews
(
action_info_dict
.
views
,
app_view
,
default_view
);
return
action_info_dict
;
});
});
})
.
declareMethod
(
"
getFormInfo
"
,
function
(
form_definition
)
{
.
declareMethod
(
"
getFormInfo
"
,
function
(
form_definition
)
{
var
child_gadget_url
,
var
child_gadget_url
,
form_type
,
form_type
,
...
@@ -176,6 +264,7 @@
...
@@ -176,6 +264,7 @@
return
pair
[
1
];
return
pair
[
1
];
});
});
form_definition
.
allowed_sub_types_list
=
allowed_sub_types
;
form_definition
.
allowed_sub_types_list
=
allowed_sub_types
;
//TODO get rid of checkViewsAndActions and use getAllViewsAndActions result instead
return
gadget
.
checkViewsAndActions
(
portal_type
,
action_type
);
return
gadget
.
checkViewsAndActions
(
portal_type
,
action_type
);
})
})
.
push
(
function
(
has_more_dict
)
{
.
push
(
function
(
has_more_dict
)
{
...
@@ -186,4 +275,4 @@
...
@@ -186,4 +275,4 @@
});
});
});
});
}(
window
,
rJS
,
Query
,
SimpleQuery
,
ComplexQuery
,
console
));
}(
window
,
rJS
,
RSVP
,
Query
,
SimpleQuery
,
ComplexQuery
,
console
));
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_common_utils_js.xml
View file @
51333e0a
...
@@ -269,7 +269,7 @@
...
@@ -269,7 +269,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
976.3
1037.9424.21862
</string>
</value>
<value>
<string>
976.3
2545.23324.47257
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -287,7 +287,7 @@
...
@@ -287,7 +287,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1560
850400.9
</float>
<float>
1560
944910.22
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.js
View file @
51333e0a
...
@@ -38,29 +38,6 @@
...
@@ -38,29 +38,6 @@
);
);
}
}
function
filterViews
(
views_dict
,
app_view
,
default_view
)
{
// there must be only one "View" action (title = "View")
// this is for scenarios were the portal type has several "View" (like view, jio_view, custom_view)
// priority: app_view ; default_view ; other
var
only_view
,
key
,
view_list
=
Object
.
keys
(
views_dict
).
map
(
function
(
key
)
{
if
(
views_dict
[
key
].
title
===
"
View
"
)
{
return
key
;
}
});
if
(
view_list
.
includes
(
app_view
))
{
only_view
=
app_view
;
}
else
if
(
view_list
.
includes
(
default_view
))
{
only_view
=
default_view
;
}
else
{
only_view
=
view_list
[
0
];
}
for
(
key
in
view_list
)
{
if
(
view_list
[
key
]
!==
only_view
)
{
delete
views_dict
[
view_list
[
key
]];
}
}
return
views_dict
;
}
gadget_klass
gadget_klass
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Acquired methods
// Acquired methods
...
@@ -107,76 +84,9 @@
...
@@ -107,76 +84,9 @@
});
});
})
})
.
declareMethod
(
"
getAllViewsAndActions
"
,
function
(
portal_type
,
options
)
{
// TODO views are also listed here
// should views be handled in another gadget like "..tab_office.js" ?
var
gadget
=
this
,
action_info_dict
=
{
views
:
{},
actions
:
{}},
//TODO use Query to avoid strings
query
=
'
portal_type: "Action Information" AND parent_relative_url: "portal_types/
'
+
portal_type
+
'
"
'
,
app_actions
,
app_view
,
default_view
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
declareGadget
(
"
gadget_officejs_common_utils.html
"
),
gadget
.
getSetting
(
'
app_view_reference
'
),
gadget
.
getSetting
(
'
default_view_reference
'
)
]);
})
.
push
(
function
(
result_list
)
{
app_view
=
result_list
[
1
];
default_view
=
result_list
[
2
];
return
result_list
[
0
].
getAppActions
(
portal_type
);
})
.
push
(
function
(
app_actions_result
)
{
app_actions
=
app_actions_result
.
map
(
function
(
pair
)
{
return
pair
[
1
];
});
return
gadget
.
jio_allDocs
({
query
:
query
})
.
push
(
function
(
action_list
)
{
var
path_for_jio_get_list
=
[],
row
;
for
(
row
in
action_list
.
data
.
rows
)
{
if
(
action_list
.
data
.
rows
.
hasOwnProperty
(
row
))
{
path_for_jio_get_list
.
push
(
gadget
.
jio_get
(
action_list
.
data
.
rows
[
row
].
id
));
}
}
return
RSVP
.
all
(
path_for_jio_get_list
);
})
.
push
(
function
(
action_document_list
)
{
var
page
,
action_key
,
action_doc
,
key
,
action_settings
;
for
(
action_key
in
action_document_list
)
{
if
(
action_document_list
.
hasOwnProperty
(
action_key
))
{
action_doc
=
action_document_list
[
action_key
];
if
(
app_actions
.
includes
(
action_doc
.
reference
))
{
action_settings
=
{
page
:
undefined
,
jio_key
:
options
.
jio_key
,
title
:
action_doc
.
title
,
action
:
action_doc
.
reference
,
reference
:
action_doc
.
reference
,
action_type
:
action_doc
.
action_type
,
parent_portal_type
:
portal_type
};
if
(
view_categories
.
includes
(
action_settings
.
action_type
))
{
action_settings
.
page
=
"
ojs_local_controller
"
;
action_info_dict
.
views
[
action_settings
.
action
]
=
action_settings
;
}
else
{
action_settings
.
page
=
"
handle_action
"
;
action_info_dict
.
actions
[
action_settings
.
action
]
=
action_settings
;
}
}
}
}
action_info_dict
.
views
=
filterViews
(
action_info_dict
.
views
,
app_view
,
default_view
);
return
action_info_dict
;
});
});
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
var
gadget
=
this
,
portal_type
,
document_title
;
document_title
;
return
gadget
.
jio_get
(
options
.
jio_key
)
return
gadget
.
jio_get
(
options
.
jio_key
)
.
push
(
function
(
document
)
{
.
push
(
function
(
document
)
{
...
@@ -186,8 +96,14 @@
...
@@ -186,8 +96,14 @@
document_title
=
options
.
portal_type
;
document_title
=
options
.
portal_type
;
return
options
.
portal_type
;
return
options
.
portal_type
;
})
})
.
push
(
function
(
portal_type
)
{
.
push
(
function
(
result
)
{
return
gadget
.
getAllViewsAndActions
(
portal_type
,
options
);
portal_type
=
result
;
return
gadget
.
declareGadget
(
"
gadget_officejs_common_utils.html
"
);
})
.
push
(
function
(
gadget_utils
)
{
// TODO views are also listed here
// should views be handled in another gadget like "..tab_office.js" ?
return
gadget_utils
.
getAllViewsAndActions
(
portal_type
,
options
.
jio_key
);
})
})
.
push
(
function
(
action_info_dict
)
{
.
push
(
function
(
action_info_dict
)
{
return
RSVP
.
all
([
return
RSVP
.
all
([
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_officejs_js.xml
View file @
51333e0a
...
@@ -228,7 +228,7 @@
...
@@ -228,7 +228,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
976.32
499.44430.52411
</string>
</value>
<value>
<string>
976.32
543.31646.51592
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15609
38148.99
</float>
<float>
15609
40816.44
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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