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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
erp5
Commits
56f24826
Commit
56f24826
authored
Aug 03, 2017
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs_afs_directory: rewrite directory to not rely on ES6 code
parent
c37b5c19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
68 deletions
+71
-68
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_page_afs_directory_js.js
...Item/web_page_module/gadget_erp5_page_afs_directory_js.js
+69
-66
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_page_afs_directory_js.xml
...tem/web_page_module/gadget_erp5_page_afs_directory_js.xml
+2
-2
No files found.
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_page_afs_directory_js.js
View file @
56f24826
/*global window, rJS, RSVP, Handlebars, URI, console, jIO, document */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
URI
,
document
)
{
/*global window, rJS, RSVP, Handlebars, jIO, document */
/*jslint indent: 2, nomen: true, maxlen: 80*/
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
document
)
{
"
use strict
"
;
var
gadget_klass
=
rJS
(
window
),
/////////////////////////////////////////////////////////////////
// some variables
/////////////////////////////////////////////////////////////////
var
VIEW
=
"
?page=afs_software&view=view
"
,
gadget_klass
=
rJS
(
window
),
templater
=
gadget_klass
.
__template_element
,
source
=
templater
.
getElementById
(
"
frontpage-template
"
)
.
innerHTML
,
source
=
templater
.
getElementById
(
"
frontpage-template
"
).
innerHTML
,
template
=
Handlebars
.
compile
(
source
);
Handlebars
.
registerPartial
(
"
list-partial
"
,
templater
.
getElementById
(
"
list-partial
"
).
innerHTML
);
gadget_klass
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
...
...
@@ -23,9 +31,7 @@
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
()
{
var
gadget
=
this
,
masonry_container
=
gadget
.
element
.
querySelector
(
'
.ui-masonry-container
'
);
grid
=
gadget
.
element
.
querySelector
(
'
.ui-masonry-container
'
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
@@ -36,67 +42,64 @@
})
]);
})
.
push
(
function
(
my_response_list
)
{
return
RSVP
.
all
([
gadget
.
jio_allDocs
({
select_list
:
[
'
category_list
'
],
query
:
'
portal_type:"software"
'
}),
my_response_list
[
0
].
render
()
]);
.
push
(
function
(
result_list
)
{
return
result_list
[
0
].
render
();
})
.
push
(
function
(
my_response_lis
t
)
{
var
softwares
=
my_response_list
[
0
].
data
.
rows
,
obj
,
.
push
(
function
(
html_conten
t
)
{
var
banner
=
document
.
createRange
()
.
createContextualFragment
(
html_content
||
""
);
// get categories and flatten array of category arrays
categories
=
softwares
.
map
((
obj
)
=>
obj
.
value
.
category_list
)
.
reduce
((
cur
,
prev
)
=>
cur
.
concat
(
prev
)),
// remove duplicates (case sensitive!)
unique_categories
=
Array
.
from
(
new
Set
(
categories
)),
// kudos: https://davidwalsh.name/convert-html-stings-dom-nodes
banner
=
document
.
createRange
()
.
createContextualFragment
(
my_response_list
[
1
]
||
""
);
gadget
.
element
.
insertBefore
(
banner
,
masonry_container
);
return
RSVP
.
all
(
unique_categories
);
})
.
push
(
function
(
categories
)
{
var
softwares_by_category
=
categories
.
map
(
function
(
category
)
{
return
gadget
.
jio_allDocs
({
select_list
:
[
'
title
'
,
'
publisher
'
,
'
logo
'
],
query
:
'
category_list:"%
'
+
category
+
'
%" AND portal_type:"software"
'
})
.
push
(
function
(
softwares
)
{
softwares
.
data
.
rows
.
map
(
function
(
sw
)
{
// XXX hardcoded page and view
sw
.
value
.
href
=
"
#/
"
+
sw
.
id
+
"
?page=afs_software&view=view
"
;
});
return
{
category
:
category
,
softwares
:
softwares
.
data
.
rows
};
});
gadget
.
element
.
insertBefore
(
banner
,
grid
);
return
gadget
.
jio_allDocs
({
select_list
:
[
'
category_list
'
,
'
title
'
,
'
publisher
'
],
query
:
'
portal_type:"software"
'
});
return
RSVP
.
all
(
softwares_by_category
);
})
.
push
(
function
(
result
)
{
var
content
;
.
push
(
function
(
result_list
)
{
var
software_list
=
result_list
.
data
.
rows
,
global_category_list
=
[],
config
;
// list of unique list of categories
if
(
software_list
.
length
>
0
)
{
global_category_list
=
software_list
.
reduce
(
function
(
list
,
dict
)
{
var
software
=
dict
.
value
;
if
(
software
.
category_list
.
length
>
0
)
{
software
.
category_list
.
map
(
function
(
category
)
{
if
(
list
.
indexOf
(
category
)
===
-
1
)
{
list
.
push
(
category
);
}
});
}
return
list
;
},
[]);
}
// populate list with software
config
=
global_category_list
.
reduce
(
function
(
result
,
category
)
{
var
category_entry
=
{
"
category
"
:
category
,
"
software_list
"
:
[]},
len
=
software_list
.
length
,
match_list
,
software
,
i
;
// reverse sort categories by number of softwares
result
.
sort
(
(
a
,
b
)
=>
b
.
softwares
.
length
-
a
.
softwares
.
length
);
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
software
=
software_list
[
i
].
value
;
match_list
=
software
.
category_list
;
if
(
match_list
&&
match_list
.
length
>
0
)
{
if
(
match_list
.
indexOf
(
category
)
>
-
1
)
{
category_entry
.
software_list
.
push
({
"
title
"
:
software
.
title
,
"
href
"
:
"
#/
"
+
software_list
[
i
].
id
+
VIEW
});
}
}
}
result
.
push
(
category_entry
);
return
result
;
},
[]);
content
=
template
(
result
);
masonry_container
.
innerHTML
=
content
;
grid
.
innerHTML
=
template
(
config
);
});
});
}(
window
,
rJS
,
RSVP
,
Handlebars
,
URI
,
document
));
}(
window
,
rJS
,
RSVP
,
Handlebars
,
document
));
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_page_afs_directory_js.xml
View file @
56f24826
...
...
@@ -228,7 +228,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
59.46981.52420.64187
</string>
</value>
<value>
<string>
9
61.9243.54613.9181
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>
1
496170069.03
</float>
<float>
1
501772325.68
</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