Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
507f9afa
Commit
507f9afa
authored
Jan 09, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
harmonized gadget scheme API for listgrid
parent
afd5a3cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
212 additions
and
100 deletions
+212
-100
api/TEMPLATE_listgrid
api/TEMPLATE_listgrid
+118
-0
data/software_overview.json
data/software_overview.json
+16
-0
js/erp5_loader.js
js/erp5_loader.js
+78
-100
No files found.
api/TEMPLATE_listgrid
0 → 100644
View file @
507f9afa
"portal_type_source": "Software Product",
"portal_type_title": "software",
"portal_type_fields": "software_fieldlist",
"initial_query": {"include_docs": true, "limit":[0,8]},
"form": true,
"id": "software_overview",
"property_dict": {
"link": true,
"link_identifier": "id",
"link_external": null,
"link_source": "item_url",
"ribbon": null,
"radio": null,
"check": null,
"dynamic_children": [0]
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "image_url", "type": "image"},
{"field": "title", "type": "alt"},
{"field": "some_translation_pointer", "type": "alt_i18n"},
{"custom": true, "type": "icon", "value": "baz"}
]
},
{
"position": "center",
"fieldlist": [
{"field": "title", "type": "h1"},
{"field": "description", "type": "p"},
{"field": "price", "type": "p", "aside": true},
{"field": "some_url", "type":"count"}
],
},
{
"position": "right",
"fieldlist": [
{"custom": true, "type": "icon", "value": "bar"},
{"field": "some_url", "type": "url", "external": true, "action": baz, "title": null, "title_i18n": null}
]
}
],
"children": [{
"generate":"widget",
"type": "listview",
"class_list": "",
"theme": "slapos-white",
"property_dict": {
"alt_icon": null
"numbered": false
"inset": true,
"reveal": true,
"filter": true,
"input": "#foo"
"placeholder": null,
"filter_theme": null,
"divider_theme": "slapos-white",
"autodividers": true,
"count_theme": "slapos-white"
},
"children": []
}]
mapped:
* {
* "generate": "gadget",
* "type": "listview",
* "class_list": "",
* "theme": "slapos-black",
* "property_dict": {
* "alt_icon": null
* "numbered": false
* "inset": true,
* "reveal": true,
* "filter": true,
* "input": "#foo"
* "placeholder": null,
* "filter_theme": null,
* "divider_theme": "slapos-white",
* "autodividers": true,
* "count_theme": "slapos-white"
* },
* "children": [
* {
* "type": "item/divider",
* "id": null,
* "external": true,
* "href": "index.html",
* "icon": "foo"/null,
* "title": null,
* "title_i18n":"",
* "left": {
* "icon": "foo",
* "image": "http://www.xyz.com/img/foo.png",
* "alt": null,
* "alt_i18n": null
* },
* "center": {
* "text": [
* {"type":"p", "aside": true, "text":"foo", "text_i18n":null},
* {"type": "span", "count": true, "text": "somevalue"}
* ]
* },
* "right": {
* "radio": true,
* "check": true,
* "icon": null,
* "action": "foo",
* "href": "http://www.foo.com",
* "title": null,
* "title_i18n": "",
* "external": true
* }
* ]
*}
\ No newline at end of file
data/software_overview.json
View file @
507f9afa
...
...
@@ -10,6 +10,22 @@
"link_identifier"
:
"id"
,
"dynamic_children"
:
[
1
]
},
"scheme"
:
[
{
"position"
:
"left"
,
"fieldlist"
:
[
{
"field"
:
"image_url"
,
"type"
:
"image"
},
{
"field"
:
"title"
,
"type"
:
"alt"
}
]
},
{
"position"
:
"center"
,
"fieldlist"
:
[
{
"field"
:
"title"
,
"type"
:
"h1"
},
{
"field"
:
"description"
,
"type"
:
"p"
}
]
}
],
"children"
:
[{
"generate"
:
"widget"
,
"type"
:
"controlbar"
,
...
...
js/erp5_loader.js
View file @
507f9afa
...
...
@@ -642,118 +642,94 @@
* @param {object} url_pointer Info which layout items are created for
* @return {object} mapped object
**/
// TODO: this should be in a storage-related utility object!
// TODO: count/aside still not implemented on listview
// TODO: add remaining mapping!
// TODO: MAKE GENERIC API with layout!
"
mapListItems
"
:
function
(
items
,
spec
,
url_pointer
)
{
var
property
,
obj
,
i
,
item
,
clean
,
value
,
store
,
split
,
host
,
i18n
,
application
,
level
,
core
,
arr
;
var
obj
,
i
,
j
,
k
,
item
,
level
,
core
,
arr
,
section
,
field
,
props
,
pos
;
level
=
url_pointer
.
layout
;
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
);
arr
=
[];
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
item
=
items
[
i
].
doc
;
obj
=
{
"
type
"
:
"
item
"
,
"
center
"
:
{
"
text
"
:
[]
}
};
if
(
spec
.
scheme
===
undefined
)
{
util
.
error
(
"
mapListItems: Missing scheme
"
);
// if include_docs is not set, item will be undefined!
if
(
item
===
undefined
)
{
util
.
error
(
"
mapListItems: missing include_docs
"
);
}
// radio
if
(
spec
.
property_dict
.
radio
)
{
obj
.
right
=
{
"
radio
"
:
true
,
"
action
"
:
"
check
"
};
}
// checkbox
if
(
spec
.
property_dict
.
check
)
{
obj
.
right
=
{
"
check
"
:
true
,
"
action
"
:
"
check
"
};
}
}
else
{
arr
=
[];
props
=
spec
.
property_dict
;
// link base for internal links
if
(
props
.
link
&&
!
props
.
link_source
)
{
level
=
url_pointer
.
layout
;
core
=
url_pointer
.
fragment_list
.
slice
(
0
,
level
+
1
).
join
(
"
::
"
);
}
// loop items and map according to scheme
for
(
i
=
0
;
i
<
items
.
length
;
i
+=
1
)
{
item
=
items
[
i
].
doc
;
obj
=
{
"
type
"
:
"
item
"
,
"
center
"
:
{
"
text
"
:
[]
}
};
// TODO: we can't handle normal URLs if they are passed!
// should only be possible if links will be external, but how to set?
if
(
spec
.
property_dict
.
link
)
{
obj
.
href
=
"
#
"
+
core
+
"
::
"
+
item
[
spec
.
property_dict
.
link_identifier
||
"
id
"
];
}
// throw error for missing data
if
(
item
===
undefined
)
{
util
.
error
(
"
mapListItems: Missing include_docs/data-set
"
);
// TODO: don't do this based on hardcoded filenames!!!
for
(
property
in
item
)
{
if
(
item
.
hasOwnProperty
(
property
))
{
clean
=
property
.
replace
((
spec
.
portal_type_title
+
"
_
"
),
""
);
}
else
{
// TODO: keep ?
// ribbon
if
(
props
.
ribbon
)
{
obj
.
ribbon
=
true
;
}
switch
(
clean
)
{
case
"
url
"
:
obj
.
href
=
item
[
property
];
split
=
item
[
property
].
split
(
"
//
"
);
// TODO: move radio/check into feature_dict and on item level?
// radio
if
(
props
.
radio
)
{
obj
.
right
=
{
"
radio
"
:
true
,
"
action
"
:
"
check
"
};
}
// TODO: crap... an empty link will generate a ribbon...
if
(
item
[
property
]
===
""
)
{
obj
.
ribbon
=
true
;
}
// checkbox
if
(
props
.
check
)
{
obj
.
right
=
{
"
check
"
:
true
,
"
action
"
:
"
check
"
}
;
}
// TODO: refactor. Determining whether a link is external
if
(
split
.
length
>
1
)
{
host
=
split
[
1
].
split
(
"
/
"
)[
0
];
application
=
split
[
1
].
split
(
"
/
"
)[
1
];
}
if
((
split
.
length
>
1
&&
window
.
location
.
host
!==
host
)
||
application
===
"
app
"
)
{
// link
if
(
props
.
link
)
{
obj
.
href
=
item
[
props
.
link_source
]
||
(
"
#
"
+
core
+
"
::
"
+
item
[
props
.
link_identifier
||
"
id
"
]);
if
(
props
.
link_external
)
{
obj
.
external
=
true
;
}
break
;
case
"
_id
"
:
obj
.
id
=
item
[
property
];
break
;
case
"
title
"
:
value
=
item
[
property
];
obj
[
clean
]
=
value
;
i18n
=
item
[
property
+
"
_i18n
"
]
||
null
;
obj
.
center
.
text
.
unshift
({
"
type
"
:
"
h1
"
,
"
text
"
:
value
,
"
text_i18n
"
:
i18n
});
break
;
case
"
description
"
:
i18n
=
item
[
property
+
"
_i18n
"
]
||
null
;
obj
.
center
.
text
.
push
({
"
type
"
:
"
p
"
,
"
text
"
:
item
[
property
],
"
text_i18n
"
:
i18n
});
break
;
case
"
image_type
"
:
obj
.
left
=
{};
obj
.
left
[
item
[
property
]]
=
(
store
!==
undefined
?
store
:
false
);
break
;
case
"
image_url
"
:
if
(
obj
.
left
!==
undefined
)
{
if
(
obj
.
left
.
image
===
false
)
{
obj
.
left
.
image
=
item
[
property
];
obj
.
left
.
alt
=
item
.
title
;
}
if
(
obj
.
left
.
icon
===
false
)
{
obj
.
left
.
icon
=
item
[
property
];
}
// loop scheme sections
for
(
j
=
0
;
j
<
spec
.
scheme
.
length
;
j
+=
1
)
{
section
=
spec
.
scheme
[
j
];
pos
=
section
.
position
;
obj
[
pos
]
=
obj
[
pos
]
||
{};
// loop scheme fields
for
(
k
=
0
;
k
<
section
.
fieldlist
.
length
;
k
+=
1
)
{
field
=
section
.
fieldlist
[
k
];
if
(
obj
[
pos
].
text
)
{
// add object to text-array
// TODO: not nice & find better handling for i18n tags!
obj
[
pos
].
text
.
push
({
"
type
"
:
field
.
type
,
"
text
"
:
item
[
field
.
field
],
"
aside
"
:
field
.
aside
||
null
,
"
count
"
:
field
.
count
||
null
,
"
text_i18n
"
:
item
[
field
.
field
+
"
_18n
"
]
||
null
});
}
else
{
// set type to item field or field value (custom fields!)
obj
[
pos
][
field
.
type
]
=
item
[
field
.
field
||
field
.
value
];
}
}
else
{
store
=
item
[
property
];
}
break
;
}
}
arr
.
push
(
obj
);
}
arr
.
push
(
obj
)
;
return
arr
;
}
return
arr
;
},
/**
...
...
@@ -2641,12 +2617,13 @@
* "left": {
* "icon": "foo",
* "image": "http://www.xyz.com/img/foo.png",
* "alt": null
* "alt": null,
* "alt_i18n": null
* },
* "center": {
* "count": 3689,
* "text": [
* {"aside": true, "type":"p", "text":"foo", "text_i18n":null}
* {"type":"p", "aside": true, "text":"foo", "text_i18n":null},
* {"type": "span", "count": true, "text": "3689"}
* ]
* },
* "right": {
...
...
@@ -2669,7 +2646,8 @@
*/
// TODO: add to form support via children
// TODO: add collapsible support if needed
// TODO: mesh with live data!
// TODO: dividers? will not be in spec, so can only be listview option!
// TODO: count/aside still not implemented on listview
factory
.
listview
=
function
(
spec
,
url_dict
,
update
)
{
var
fragment
,
config
,
list
,
i
,
item
,
props
,
divider
,
static_item
,
j
,
input_dict
,
action
,
block
,
target
,
icon
,
auto
,
last
,
...
...
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