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
73e720ba
Commit
73e720ba
authored
May 05, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: get rid of hardcoded post module rendering (WIP)
- use generic form view to render post list form
parent
eb3a5942
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
138 deletions
+84
-138
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.js
...web_page_module/gadget_officejs_erp5_page_post_list_js.js
+74
-131
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.xml
...eb_page_module/gadget_officejs_erp5_page_post_list_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_form_view_js.js
...plateItem/web_page_module/gadget_officejs_form_view_js.js
+6
-3
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_form_view_js.xml
...lateItem/web_page_module/gadget_officejs_form_view_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.js
View file @
73e720ba
/*global window, rJS, RSVP */
/*global window,
document,
rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
document
,
rJS
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
rJS
(
window
)
rJS
(
window
)
...
@@ -17,10 +17,9 @@
...
@@ -17,10 +17,9 @@
// declared methods
// declared methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
generateJsonRenderForm
"
,
function
(
gadget
)
{
//HARDCODED UNTIL form_def is stored in local storage
//this will be the id of the thread that contains this post list
.
declareMethod
(
"
getFormDefinition
"
,
function
(
gadget
)
{
var
fake_thread_uid
=
"
thread-
"
+
(
"
0000
"
+
((
Math
.
random
()
*
Math
.
pow
(
36
,
4
))
|
0
).
toString
(
36
)).
slice
(
-
4
),
var
fake_thread_uid
=
"
thread-
"
+
(
"
0000
"
+
((
Math
.
random
()
*
Math
.
pow
(
36
,
4
))
|
0
).
toString
(
36
)).
slice
(
-
4
),
// get these (portal_type, etc) from getSettings
action_info
=
{
action_info
=
{
page
:
"
handle_action
"
,
page
:
"
handle_action
"
,
action
:
"
new
"
,
action
:
"
new
"
,
...
@@ -28,7 +27,6 @@
...
@@ -28,7 +27,6 @@
parent_portal_type
:
"
Post Module
"
,
parent_portal_type
:
"
Post Module
"
,
my_source_reference
:
fake_thread_uid
my_source_reference
:
fake_thread_uid
},
},
//hardcoded form_definition (this should come from erp5 form)
form_definition
=
{
form_definition
=
{
_debug
:
"
traverse
"
,
_debug
:
"
traverse
"
,
pt
:
"
form_view
"
,
pt
:
"
form_view
"
,
...
@@ -37,16 +35,19 @@
...
@@ -37,16 +35,19 @@
"
bottom
"
,
"
bottom
"
,
[[
"
my_listbox
"
]]
[[
"
my_listbox
"
]]
]],
]],
//this field
_info
is totally made up, but somewhere in the definition there must be
//this field
s_raw_properties
is totally made up, but somewhere in the definition there must be
//information about the fields. So, foreach field: key->info
//information about the fields. So, foreach field: key->info
field
_info_dict
:
{
field
s_raw_properties
:
{
"
my_listbox
"
:
{
"
my_listbox
"
:
{
"
type
"
:
"
ListBox
"
,
"
key
"
:
"
field_listbox
"
,
// or my_listbox ??
"
values
"
:
{
"
column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
show_anchor
"
:
0
,
"
show_anchor
"
:
0
,
"
default_params
"
:
{},
"
default_params
"
:
{},
"
editable
"
:
1
,
"
editable
"
:
1
,
"
editable_column_list
"
:
[],
"
editable_column_list
"
:
[],
"
key
"
:
"
field_listbox
"
,
//
"key": "field_listbox",
"
lines
"
:
30
,
"
lines
"
:
30
,
"
list_method
"
:
"
portal_catalog
"
,
"
list_method
"
:
"
portal_catalog
"
,
// is this correct? the query should come from the form definition, right?
// is this correct? the query should come from the form definition, right?
...
@@ -55,128 +56,70 @@
...
@@ -55,128 +56,70 @@
"
search_column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
search_column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
sort_column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
sort_column_list
"
:
[[
'
title
'
,
'
Title
'
],
[
'
modification_date
'
,
'
Modification Date
'
]],
"
sort
"
:
[[
'
modification_date
'
,
'
descending
'
]],
"
sort
"
:
[[
'
modification_date
'
,
'
descending
'
]],
"
title
"
:
"
Posts
"
,
"
title
"
:
"
Posts
"
"
type
"
:
"
ListBox
"
//"type": "ListBox"
},
"
tales
"
:
{},
"
overrides
"
:
{},
"
message_values
"
:
{}
}
}
},
},
action
:
"
Base_edit
"
,
action
:
"
Base_edit
"
,
update_action
:
""
,
update_action
:
""
,
_links
:
{
"
type
"
:
{
name
:
""
},
"
action_object_new_content_action
"
:
action_info
}
_links
:
{
"
type
"
:
{
name
:
""
},
"
action_object_new_content_action
"
:
action_info
}
},
form_json
=
{
erp5_document
:
{
"
_embedded
"
:
{
"
_view
"
:
{}},
"
_links
"
:
{}
},
form_definition
:
form_definition
};
};
for
(
var
i
=
0
;
i
<
form_definition
.
group_list
.
length
;
i
++
)
{
return
form_definition
;
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
;
})
})
.
allowPublicAcquisition
(
'
notifySubmit
'
,
function
()
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
return
this
.
triggerSubmit
();
var
gadget
=
this
,
default_view
=
"
jio_view
"
,
common_utils_gadget_url
=
"
gadget_officejs_common_utils.html
"
,
child_gadget_url
=
'
gadget_erp5_pt_form_list.html
'
;
return
gadget
.
declareGadget
(
common_utils_gadget_url
)
.
push
(
function
(
gadget_utils
)
{
return
gadget
.
getFormDefinition
();
//return gadget_utils.getFormDefinition(jio_document.portal_type, default_view);
})
})
.
push
(
function
(
form_definition
)
{
.
declareMethod
(
"
triggerSubmit
"
,
function
()
{
return
gadget
.
changeState
({
var
argument_list
=
arguments
;
jio_key
:
options
.
jio_key
,
return
this
.
getDeclaredGadget
(
'
form_list
'
)
child_gadget_url
:
child_gadget_url
,
.
push
(
function
(
gadget
)
{
form_definition
:
form_definition
,
return
gadget
.
triggerSubmit
.
apply
(
gadget
,
argument_list
);
form_type
:
'
list
'
,
editable
:
false
,
view
:
default_view
,
front_page
:
true
,
has_more_views
:
false
,
//this should come from form_def
has_more_actions
:
false
//this should come from form_def
});
});
});
})
})
.
declareMethod
(
"
render
"
,
function
()
{
.
onStateChange
(
function
()
{
var
gadget
=
this
,
var
fragment
=
document
.
createElement
(
'
div
'
),
erp5_document
;
gadget
=
this
,
return
new
RSVP
.
Queue
()
options
;
.
push
(
function
()
{
while
(
this
.
element
.
firstChild
)
{
return
RSVP
.
all
([
this
.
element
.
removeChild
(
this
.
element
.
firstChild
);
gadget
.
getDeclaredGadget
(
'
form_list
'
),
gadget
.
generateJsonRenderForm
(
gadget
)
]);
})
.
push
(
function
(
result
)
{
erp5_document
=
result
[
1
].
erp5_document
;
return
result
[
0
].
render
(
result
[
1
]);
})
// render the header
.
push
(
function
()
{
var
url_for_parameter_list
=
[
{
command
:
'
change
'
,
options
:
{
page
:
"
tab
"
}},
{
command
:
'
change
'
,
options
:
{
page
:
"
action
"
}},
{
command
:
'
history_previous
'
},
{
command
:
'
selection_previous
'
},
{
command
:
'
selection_next
'
},
{
command
:
'
change
'
,
options
:
{
page
:
"
export
"
}},
{
command
:
'
display
'
,
options
:
{}}
];
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
([
this
.
element
.
appendChild
(
fragment
);
gadget
.
getUrlForList
(
url_for_parameter_list
)
,
return
gadget
.
declareGadget
(
"
gadget_officejs_form_view.html
"
,
{
element
:
fragment
,
gadget
.
isDesktopMedia
(),
scope
:
'
form_view
'
})
gadget
.
getSetting
(
'
document_title_plural
'
),
.
push
(
function
(
form_view_gadget
)
{
gadget
.
getSetting
(
'
upload_dict
'
,
false
)
return
form_view_gadget
.
render
(
gadget
.
state
);
]
);
}
);
})
})
.
push
(
function
(
result_list
)
{
var
is_form_list
=
true
,
//TODO: configuration must indicate if is a form or list view
.
declareMethod
(
"
triggerSubmit
"
,
function
()
{
url_list
=
result_list
[
0
],
header_dict
;
var
argument_list
=
arguments
;
if
(
is_form_list
)
{
return
this
.
getDeclaredGadget
(
'
form_view
'
)
header_dict
=
{
.
push
(
function
(
view_gadget
)
{
panel_action
:
true
,
return
view_gadget
.
getDeclaredGadget
(
'
fg
'
);
jump_url
:
""
,
})
fast_input_url
:
""
,
.
push
(
function
(
gadget
)
{
filter_action
:
true
,
return
gadget
.
triggerSubmit
.
apply
(
gadget
,
argument_list
);
page_title
:
result_list
[
2
]
};
if
(
result_list
[
4
])
{
header_dict
.
upload_url
=
result_list
[
3
];
}
}
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
(
false
)
{
//TODO: configuration must indicate if there are more views
header_dict
.
tab_url
=
url_list
[
0
];
}
if
(
gadget
.
state
.
editable
===
"
true
"
)
{
header_dict
.
save_action
=
true
;
}
}
if
(
false
)
{
//TODO: configuration must indicate if there are 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
);
});
});
});
});
}(
window
,
rJS
,
RSVP
));
\ No newline at end of file
}(
window
,
document
,
rJS
,
RSVP
));
\ No newline at end of file
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.xml
View file @
73e720ba
...
@@ -269,7 +269,7 @@
...
@@ -269,7 +269,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.
17663.19549.38007
</string>
</value>
<value>
<string>
975.
33670.15324.9233
</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>
155
6202309.4
3
</float>
<float>
155
7077120.6
3
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_form_view_js.js
View file @
73e720ba
...
@@ -114,7 +114,7 @@
...
@@ -114,7 +114,7 @@
})
})
.
declareMethod
(
"
renderSubGadget
"
,
function
(
options
,
subgadget
,
form_json
)
{
.
declareMethod
(
"
renderSubGadget
"
,
function
(
options
,
subgadget
,
form_json
)
{
var
this_gadget
=
this
,
erp5_document
=
form_json
.
erp5_document
;
var
this_gadget
=
this
,
erp5_document
=
form_json
.
erp5_document
,
add_url
;
return
subgadget
.
render
({
return
subgadget
.
render
({
jio_key
:
options
.
jio_key
,
jio_key
:
options
.
jio_key
,
doc
:
options
.
doc
,
doc
:
options
.
doc
,
...
@@ -138,6 +138,7 @@
...
@@ -138,6 +138,7 @@
erp5_document
=
form_json
.
erp5_document
;
erp5_document
=
form_json
.
erp5_document
;
if
(
erp5_document
.
_links
&&
erp5_document
.
_links
.
action_object_new_content_action
)
{
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
});
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
erp5_document
.
_links
.
action_object_new_content_action
});
add_url
=
true
;
}
}
return
RSVP
.
all
([
return
RSVP
.
all
([
this_gadget
.
getUrlForList
(
url_for_parameter_list
),
this_gadget
.
getUrlForList
(
url_for_parameter_list
),
...
@@ -160,10 +161,12 @@
...
@@ -160,10 +161,12 @@
panel_action
:
true
,
panel_action
:
true
,
jump_url
:
""
,
jump_url
:
""
,
fast_input_url
:
""
,
fast_input_url
:
""
,
front_url
:
url_list
[
6
],
filter_action
:
true
,
filter_action
:
true
,
page_title
:
result_list
[
2
]
page_title
:
result_list
[
2
]
};
};
if
(
!
options
.
front_page
)
{
header_dict
.
front_url
=
url_list
[
6
];
}
}
else
{
}
else
{
header_dict
=
{
header_dict
=
{
selection_url
:
url_list
[
2
],
selection_url
:
url_list
[
2
],
...
@@ -181,7 +184,7 @@
...
@@ -181,7 +184,7 @@
if
(
options
.
has_more_actions
)
{
if
(
options
.
has_more_actions
)
{
header_dict
.
actions_url
=
url_list
[
1
];
header_dict
.
actions_url
=
url_list
[
1
];
}
}
if
(
url_list
[
url_list
.
length
-
1
]
)
{
if
(
add_url
)
{
header_dict
.
add_url
=
url_list
[
url_list
.
length
-
1
];
header_dict
.
add_url
=
url_list
[
url_list
.
length
-
1
];
}
}
if
(
result_list
[
1
])
{
if
(
result_list
[
1
])
{
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_form_view_js.xml
View file @
73e720ba
...
@@ -269,7 +269,7 @@
...
@@ -269,7 +269,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.
29199.21743.1211
</string>
</value>
<value>
<string>
975.
33665.55580.31300
</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>
155
6807969.14
</float>
<float>
155
7076245.43
</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