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
Papa Tamsir Kane
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
Show 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 */
/*global window, rJS, RSVP, Handlebars, jIO, document */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint indent: 2, nomen: true, maxlen: 80*/
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
document
)
{
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
URI
,
document
)
{
"
use strict
"
;
"
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
,
templater
=
gadget_klass
.
__template_element
,
source
=
templater
.
getElementById
(
"
frontpage-template
"
)
source
=
templater
.
getElementById
(
"
frontpage-template
"
).
innerHTML
,
.
innerHTML
,
template
=
Handlebars
.
compile
(
source
);
template
=
Handlebars
.
compile
(
source
);
Handlebars
.
registerPartial
(
Handlebars
.
registerPartial
(
"
list-partial
"
,
"
list-partial
"
,
templater
.
getElementById
(
"
list-partial
"
).
innerHTML
templater
.
getElementById
(
"
list-partial
"
).
innerHTML
);
);
gadget_klass
gadget_klass
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
...
@@ -23,9 +31,7 @@
...
@@ -23,9 +31,7 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
()
{
.
declareMethod
(
"
render
"
,
function
()
{
var
gadget
=
this
,
var
gadget
=
this
,
masonry_container
=
gadget
.
element
.
querySelector
(
grid
=
gadget
.
element
.
querySelector
(
'
.ui-masonry-container
'
);
'
.ui-masonry-container
'
);
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
...
@@ -36,67 +42,64 @@
...
@@ -36,67 +42,64 @@
})
})
]);
]);
})
})
.
push
(
function
(
my_response_list
)
{
.
push
(
function
(
result_list
)
{
return
RSVP
.
all
([
return
result_list
[
0
].
render
();
gadget
.
jio_allDocs
({
select_list
:
[
'
category_list
'
],
query
:
'
portal_type:"software"
'
}),
my_response_list
[
0
].
render
()
]);
})
})
.
push
(
function
(
my_response_lis
t
)
{
.
push
(
function
(
html_conten
t
)
{
var
softwares
=
my_response_list
[
0
].
data
.
rows
,
var
banner
=
document
.
createRange
()
obj
,
.
createContextualFragment
(
html_content
||
""
);
// get categories and flatten array of category arrays
gadget
.
element
.
insertBefore
(
banner
,
grid
);
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
({
return
gadget
.
jio_allDocs
({
select_list
:
[
select_list
:
[
'
category_list
'
,
'
title
'
,
'
publisher
'
],
'
title
'
,
query
:
'
portal_type:"software"
'
'
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
};
});
});
})
.
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
;
},
[]);
}
return
RSVP
.
all
(
softwares_by_category
);
// populate list with software
})
config
=
global_category_list
.
reduce
(
function
(
result
,
category
)
{
.
push
(
function
(
result
)
{
var
category_entry
=
{
"
category
"
:
category
,
"
software_list
"
:
[]},
var
content
;
len
=
software_list
.
length
,
match_list
,
software
,
i
;
// reverse sort categories by number of softwares
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
result
.
sort
(
(
a
,
b
)
=>
b
.
softwares
.
length
-
a
.
softwares
.
length
);
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
);
grid
.
innerHTML
=
template
(
config
);
masonry_container
.
innerHTML
=
content
;
});
});
});
});
}(
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 @@
...
@@ -228,7 +228,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<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>
<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>
1
496170069.03
</float>
<float>
1
501772325.68
</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