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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
ea3b93fb
Commit
ea3b93fb
authored
Oct 27, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Rewrite relation field
Support calling render method multiple times.
parent
7b480c8f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
608 additions
and
495 deletions
+608
-495
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multirelationstringfield_js.js
...age_module/rjs_gadget_erp5_multirelationstringfield_js.js
+203
-114
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multirelationstringfield_js.xml
...ge_module/rjs_gadget_erp5_multirelationstringfield_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_html.html
.../web_page_module/rjs_gadget_erp5_relation_input_html.html
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_html.xml
...m/web_page_module/rjs_gadget_erp5_relation_input_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_js.js
...Item/web_page_module/rjs_gadget_erp5_relation_input_js.js
+321
-355
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_js.xml
...tem/web_page_module/rjs_gadget_erp5_relation_input_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relationstringfield_js.js
...web_page_module/rjs_gadget_erp5_relationstringfield_js.js
+65
-7
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relationstringfield_js.xml
...eb_page_module/rjs_gadget_erp5_relationstringfield_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
...TemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
+6
-6
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
...emplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multirelationstringfield_js.js
View file @
ea3b93fb
/*jslint indent: 2, maxerr: 3, nomen: true */
/*jslint indent: 2, maxerr: 3, nomen: true
, unparam: true, maxlen: 80
*/
/*global window, rJS, RSVP, document */
(
function
(
window
,
rJS
,
RSVP
,
document
)
{
"
use strict
"
;
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.
ready
(
function
(
gadget
)
{
gadget
.
props
=
{};
return
gadget
.
getElement
()
.
push
(
function
(
element
)
{
gadget
.
props
.
element
=
element
;
});
function
addRelationInput
(
gadget
,
value_relative_url
,
value_text
,
value_uid
,
value_portal_type
,
index
)
{
var
input_gadget
;
return
gadget
.
declareGadget
(
'
gadget_erp5_relation_input.html
'
,
{
element
:
document
.
createElement
(
"
fieldset
"
)
})
.
allowPublicAcquisition
(
"
addRelationInput
"
,
function
()
{
var
fieldset
=
document
.
createElement
(
"
fieldset
"
),
gadget
=
this
,
container
=
gadget
.
props
.
element
.
querySelector
(
'
.container
'
);
return
gadget
.
declareGadget
(
'
gadget_erp5_relation_input.html
'
,
{
element
:
fieldset
})
.
push
(
function
(
relation_input
)
{
var
field_json
=
gadget
.
props
.
field_json
,
index
;
if
(
field_json
.
default
.
value
)
{
index
=
field_json
.
default
.
relation_item_relative_url
.
length
;
field_json
.
default
.
relation_item_relative_url
.
push
(
''
);
field_json
.
default
.
value
.
push
(
''
);
}
else
{
index
=
field_json
.
relation_item_relative_url
.
length
;
field_json
.
relation_item_relative_url
.
push
(
''
);
field_json
.
default
.
push
(
''
);
}
gadget
.
props
.
gadget_list
.
push
(
relation_input
);
return
relation_input
.
render
({
field_json
:
gadget
.
props
.
field_json
},
{
index
:
index
,
addRelationInput
:
true
});
})
.
push
(
function
()
{
container
.
appendChild
(
fieldset
);
.
push
(
function
(
result
)
{
input_gadget
=
result
;
return
input_gadget
.
render
({
editable
:
gadget
.
state
.
editable
,
query
:
gadget
.
state
.
query
,
catalog_index
:
gadget
.
state
.
catalog_index
,
allow_jump
:
gadget
.
state
.
allow_jump
,
// required: field_json.required,
title
:
gadget
.
state
.
title
,
key
:
gadget
.
state
.
key
,
view
:
gadget
.
state
.
view
,
url
:
gadget
.
state
.
url
,
allow_creation
:
gadget
.
state
.
allow_creation
,
portal_types
:
gadget
.
state
.
portal_types
,
value_relative_url
:
value_relative_url
,
value_text
:
value_text
,
value_uid
:
value_uid
,
value_portal_type
:
value_portal_type
,
relation_index
:
index
});
})
})
.
push
(
function
()
{
gadget
.
element
.
appendChild
(
input_gadget
.
element
);
});
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
field_json
=
options
.
field_json
||
{},
state_dict
=
{
editable
:
field_json
.
editable
,
query
:
field_json
.
query
,
catalog_index
:
field_json
.
catalog_index
,
allow_jump
:
field_json
.
allow_jump
,
required
:
field_json
.
required
,
title
:
field_json
.
title
,
key
:
field_json
.
key
,
view
:
field_json
.
view
,
url
:
field_json
.
url
,
allow_creation
:
field_json
.
allow_creation
,
portal_types
:
field_json
.
portal_types
,
relation_field_id
:
field_json
.
relation_field_id
};
if
(
field_json
.
default
.
hasOwnProperty
(
'
value_text_list
'
))
{
//load non saved value
state_dict
.
value_relative_url_list
=
JSON
.
stringify
(
field_json
.
default
.
value_relative_url_list
);
state_dict
.
value_text_list
=
JSON
.
stringify
(
field_json
.
default
.
value_text_list
);
state_dict
.
value_uid_list
=
JSON
.
stringify
(
field_json
.
default
.
value_uid_list
);
state_dict
.
value_portal_type_list
=
JSON
.
stringify
(
field_json
.
default
.
value_portal_type_list
);
}
else
{
state_dict
.
value_relative_url_list
=
JSON
.
stringify
(
field_json
.
relation_item_relative_url
);
state_dict
.
value_text_list
=
JSON
.
stringify
(
field_json
.
default
);
state_dict
.
value_uid_list
=
JSON
.
stringify
([]);
state_dict
.
value_portal_type_list
=
JSON
.
stringify
([]);
}
return
this
.
changeState
(
state_dict
);
})
.
onStateChange
(
function
()
{
var
gadget
=
this
,
i
,
list
=
[],
fieldset
,
container
=
gadget
.
props
.
element
.
querySelector
(
'
.container
'
),
field_json
=
options
.
field_json
||
{},
relation_item_relative_url
;
gadget
.
props
.
field_json
=
field_json
;
if
(
field_json
.
default
.
value
)
{
if
(
field_json
.
default
.
relation_item_relative_url
[
field_json
.
default
.
relation_item_relative_url
.
length
-
1
])
{
//return form listbox
field_json
.
default
.
value
.
push
(
""
);
field_json
.
default
.
relation_item_relative_url
.
push
(
""
);
}
relation_item_relative_url
=
field_json
.
default
.
relation_item_relative_url
;
}
else
{
field_json
.
relation_item_relative_url
.
push
(
''
);
field_json
.
default
.
push
(
''
);
relation_item_relative_url
=
field_json
.
relation_item_relative_url
;
queue
=
new
RSVP
.
Queue
(),
element
=
gadget
.
element
,
value_relative_url_list
=
JSON
.
parse
(
gadget
.
state
.
value_relative_url_list
),
value_text_list
=
JSON
.
parse
(
gadget
.
state
.
value_text_list
),
value_uid_list
=
JSON
.
parse
(
gadget
.
state
.
value_uid_list
),
value_portal_type_list
=
JSON
.
parse
(
gadget
.
state
.
value_portal_type_list
);
// Always display an empty value at the end
value_relative_url_list
.
push
(
""
);
value_text_list
.
push
(
""
);
// Clear first to DOM, append after to reduce flickering/manip
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
for
(
i
=
0
;
i
<
relation_item_relative_url
.
length
;
i
+=
1
)
{
fieldset
=
document
.
createElement
(
"
fieldset
"
);
container
.
appendChild
(
fieldset
);
list
.
push
(
gadget
.
declareGadget
(
'
gadget_erp5_relation_input.html
'
,
{
element
:
fieldset
}));
function
enQueue
()
{
var
argument_list
=
arguments
;
queue
.
push
(
function
()
{
return
addRelationInput
.
apply
(
this
,
argument_list
);
});
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
list
);
for
(
i
=
0
;
i
<
value_relative_url_list
.
length
;
i
+=
1
)
{
enQueue
(
gadget
,
value_relative_url_list
[
i
],
value_text_list
[
i
],
value_uid_list
[
i
],
value_portal_type_list
[
i
],
i
);
}
return
queue
;
})
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
allowPublicAcquisition
(
'
notifyChange
'
,
function
(
argument_list
,
scope
)
{
// An empty relation should be created when the last one is modified
// An empty relation should be removed
var
gadget
=
this
,
sub_gadget
;
return
gadget
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
result
)
{
sub_gadget
=
result
;
return
sub_gadget
.
getContent
();
})
.
push
(
function
(
gadget_list
)
{
list
=
[];
gadget
.
props
.
gadget_list
=
gadget_list
;
for
(
i
=
0
;
i
<
gadget_list
.
length
;
i
+=
1
)
{
list
.
push
(
gadget_list
[
i
].
render
(
options
,
{
index
:
i
,
addRelationInput
:
(
i
===
gadget_list
.
length
-
1
)
}));
.
push
(
function
(
result
)
{
var
value
=
result
.
value_text
;
if
(
sub_gadget
.
element
===
gadget
.
element
.
lastChild
)
{
if
(
value
)
{
return
addRelationInput
(
gadget
,
''
,
''
,
undefined
,
undefined
,
gadget
.
element
.
childNodes
.
length
);
}
/*
} else {
if (!value) {
gadget.element.removeChild(sub_gadget.element);
}
*/
}
return
RSVP
.
all
(
list
);
})
.
push
(
function
()
{
return
gadget
.
notifyChange
();
});
})
.
declareMethod
(
'
getContent
'
,
function
(
options
)
{
var
list
=
[],
i
,
gadget
=
this
,
length
=
gadget
.
props
.
gadget_list
.
length
;
if
(
options
.
format
===
'
erp5
'
)
{
length
-=
1
;
}
for
(
i
=
0
;
i
<
length
;
i
+=
1
)
{
list
.
push
(
gadget
.
props
.
gadget_list
[
i
].
getContent
(
options
,
{
"
type
"
:
"
MultiRelationField
"
}));
var
i
,
element
=
this
.
element
,
queue
=
new
RSVP
.
Queue
(),
final_result
=
{},
result_list
=
[],
gadget
=
this
;
function
calculateSubContent
(
node
)
{
queue
.
push
(
function
()
{
var
scope
=
node
.
getAttribute
(
'
data-gadget-scope
'
);
if
(
scope
!==
null
)
{
return
gadget
.
getDeclaredGadget
(
node
.
getAttribute
(
'
data-gadget-scope
'
)
)
.
push
(
function
(
result
)
{
return
result
.
getContent
();
})
.
push
(
function
(
result
)
{
result_list
.
push
(
result
);
});
}
});
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
list
);
})
.
push
(
function
(
result
)
{
var
tmp
=
{},
key
,
key1
;
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
)
{
for
(
key
in
result
[
i
])
{
if
(
result
[
i
].
hasOwnProperty
(
key
))
{
if
(
options
.
format
===
'
erp5
'
)
{
if
(
tmp
[
key
]
===
undefined
)
{
tmp
[
key
]
=
[];
}
tmp
[
key
].
push
(
result
[
i
][
key
]);
}
else
{
if
(
tmp
[
key
]
===
undefined
)
{
tmp
[
key
]
=
{};
}
for
(
key1
in
result
[
i
][
key
])
{
if
(
result
[
i
][
key
].
hasOwnProperty
(
key1
))
{
if
(
tmp
[
key
][
key1
]
===
undefined
)
{
tmp
[
key
][
key1
]
=
[];
}
tmp
[
key
][
key1
].
push
(
result
[
i
][
key
][
key1
][
0
]);
if
(
this
.
state
.
editable
)
{
for
(
i
=
0
;
i
<
element
.
childNodes
.
length
;
i
+=
1
)
{
calculateSubContent
(
element
.
childNodes
[
i
]);
}
return
queue
.
push
(
function
()
{
var
result
=
{},
j
,
k
=
0
,
input_result
;
if
(
options
.
format
===
"
erp5
"
)
{
result
[
gadget
.
state
.
key
]
=
[];
}
else
{
result
[
gadget
.
state
.
key
]
=
{
value_text_list
:
[],
value_relative_url_list
:
[],
value_portal_type_list
:
[],
value_uid_list
:
[]
};
}
for
(
j
=
0
;
j
<
result_list
.
length
;
j
+=
1
)
{
input_result
=
result_list
[
j
];
if
(
options
.
format
===
"
erp5
"
)
{
if
(
input_result
.
hasOwnProperty
(
'
value_text
'
))
{
if
(
input_result
.
value_text
)
{
if
(
input_result
.
value_portal_type
)
{
result
[
gadget
.
state
.
relation_field_id
+
'
_
'
+
k
]
=
"
_newContent_
"
+
input_result
.
value_portal_type
;
}
result
[
gadget
.
state
.
key
].
push
(
input_result
.
value_text
);
}
}
k
+=
1
;
}
else
{
result
[
gadget
.
state
.
key
].
value_text_list
.
push
(
input_result
.
value_text
);
result
[
gadget
.
state
.
key
].
value_relative_url_list
.
push
(
input_result
.
value_relative_url
);
result
[
gadget
.
state
.
key
].
value_portal_type_list
.
push
(
input_result
.
value_portal_type
);
result
[
gadget
.
state
.
key
].
value_uid_list
.
push
(
undefined
);
}
}
}
return
tmp
;
});
return
result
;
});
}
return
final_result
;
});
}(
window
,
rJS
,
RSVP
,
document
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_multirelationstringfield_js.xml
View file @
ea3b93fb
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
2.33012.29157.25361
</string>
</value>
<value>
<string>
95
4.57674.49472.38673
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
14
68331865.64
</float>
<float>
14
77584183.47
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_html.html
View file @
ea3b93fb
...
...
@@ -3,7 +3,7 @@
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<title>
ERP5 Relation
stringfield
</title>
<title>
ERP5 Relation
Input
</title>
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"jiodev.js"
type=
"text/javascript"
></script>
...
...
@@ -18,9 +18,9 @@
</script>
<script
id=
"relation-input-template"
type=
"text/x-handlebars-template"
>
<
div
class
=
"
relation-input ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear ui-input-has-icon
{{readonly}}
"
>
<
div
class
=
"
relation-input ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear ui-input-has-icon
"
>
<
div
>
<
input
type
=
'
search
'
title
=
"
{{title}}
"
name
=
"
{{name}}
"
autocomplete
=
"
off
"
{{{
input_readonly
}}}
data
-
enhanced
=
"
true
"
value
=
"
{{value}}
"
>
<
input
type
=
'
search
'
title
=
"
{{title}}
"
name
=
"
{{name}}
"
autocomplete
=
"
off
"
data
-
enhanced
=
"
true
"
value
=
"
{{value}}
"
>
<
ul
class
=
"
ui-listview ui-corner-all search_ul
"
><
/ul
>
<
/div
>
<
a
href
=
{{
href
}}
tabindex
=
"
-1
"
class
=
"
{{class_name}}
"
>
Jump
to
this
document
<
/a
>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_html.xml
View file @
ea3b93fb
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.
45675.44850.53452
</string>
</value>
<value>
<string>
954.
54399.20164.63317
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
147
6956228.04
</float>
<float>
147
7475951.1
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_js.js
View file @
ea3b93fb
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, rJS, RSVP, URI,
loopEventListener,
Handlebars,
/*jslint indent: 2, maxerr: 3, nomen: true
, maxlen: 80
*/
/*global window, rJS, RSVP, URI, Handlebars,
SimpleQuery, ComplexQuery, Query, QueryFactory, promiseEventListener*/
(
function
(
window
,
rJS
,
RSVP
,
URI
,
loopEventListener
,
promiseEventListener
,
(
function
(
window
,
rJS
,
RSVP
,
URI
,
promiseEventListener
,
SimpleQuery
,
ComplexQuery
,
Query
,
QueryFactory
,
Handlebars
)
{
"
use strict
"
;
...
...
@@ -21,37 +21,43 @@
relation_listview_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
relation-listview-template
"
)
.
innerHTML
,
relation_listview_template
=
Handlebars
.
compile
(
relation_listview_source
)
,
relation_listview_template
=
Handlebars
.
compile
(
relation_listview_source
)
;
searching
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-input-clear ui-icon-spinner ui-icon-spin
"
,
jump_on
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plane ui-shadow-inset ui-btn-inline
"
,
jump_off
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plane ui-shadow-inset ui-btn-inline ui-disabled
"
,
jump_add
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plus ui-shadow-inset ui-btn-inline ui-disabled
"
,
jump_unknown
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-warning ui-shadow-inset ui-btn-inline ui-disabled
"
;
function
displayNonEditableLink
(
gadget
)
{
return
gadget
.
getUrlFor
({
command
:
'
index
'
,
options
:
{
jio_key
:
gadget
.
state
.
value_relative_url
}
})
.
push
(
function
(
href
)
{
// XXX Use html5 element gadget
gadget
.
element
.
innerHTML
=
relation_link_template
({
value
:
gadget
.
state
.
value_text
,
href
:
href
});
});
}
function
displayNonEditableText
(
gadget
)
{
gadget
.
element
.
textContent
=
gadget
.
state
.
value_text
;
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.
ready
(
function
(
my_gadget
)
{
my_gadget
.
props
=
{
input_deferred
:
RSVP
.
defer
()
};
return
my_gadget
.
getElement
()
.
push
(
function
(
element
)
{
my_gadget
.
props
.
element
=
element
;
});
})
function
displayEditableLink
(
gadget
,
class_name
)
{
return
gadget
.
translateHtml
(
relation_input_template
({
href
:
"
#
"
,
value
:
gadget
.
state
.
value_text
,
title
:
gadget
.
state
.
title
,
name
:
gadget
.
state
.
key
,
class_name
:
class_name
}))
.
push
(
function
(
html
)
{
gadget
.
element
.
innerHTML
=
html
;
});
}
gadget_klass
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
...
...
@@ -62,375 +68,335 @@
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareAcquiredMethod
(
"
getFormContent
"
,
"
getFormContent
"
)
.
declareAcquiredMethod
(
"
translateHtml
"
,
"
translateHtml
"
)
.
declareAcquiredMethod
(
"
addRelationInput
"
,
"
addRelationInput
"
)
// .declareAcquiredMethod("addRelationInput", "addRelationInput")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
render
'
,
function
(
options
,
options2
)
{
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
state_dict
=
{
editable
:
options
.
editable
,
query
:
options
.
query
,
catalog_index
:
options
.
catalog_index
,
allow_jump
:
options
.
allow_jump
,
// required: field_json.required,
title
:
options
.
title
,
key
:
options
.
key
,
view
:
options
.
view
,
url
:
options
.
url
,
allow_creation
:
options
.
allow_creation
,
portal_types
:
options
.
portal_types
,
has_focus
:
false
,
relation_index
:
options
.
relation_index
,
value_relative_url
:
options
.
value_relative_url
,
value_uid
:
options
.
value_uid
,
value_text
:
options
.
value_text
,
value_portal_type
:
options
.
value_portal_type
};
return
this
.
changeState
(
state_dict
);
})
.
onStateChange
(
function
(
modification_dict
)
{
var
gadget
=
this
,
field_json
=
options
.
field_json
||
{},
target_url
,
queue
=
new
RSVP
.
Queue
(),
create_object
,
unknown
,
relation_item_relative_url
,
uid
,
value
=
""
,
not_selected
=
true
,
index
=
options2
.
index
||
0
;
gadget
.
props
.
field_json
=
field_json
;
if
(
!
field_json
.
editable
)
{
if
(
field_json
.
relation_item_relative_url
)
{
return
gadget
.
getUrlFor
({
command
:
'
index
'
,
options
:
{
jio_key
:
field_json
.
relation_item_relative_url
[
index
]
}
})
.
push
(
function
(
href
)
{
gadget
.
props
.
element
.
innerHTML
=
relation_link_template
({
value
:
field_json
.
default
[
index
]
||
""
,
href
:
href
});
});
value_text
=
gadget
.
state
.
value_text
,
// target_url,
SEARCHING_CLASS_STR
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-input-clear ui-icon-spinner ui-icon-spin
"
,
JUMP_ON_CLASS_STR
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plane ui-shadow-inset ui-btn-inline
"
,
JUMP_OFF_CLASS_STR
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plane ui-shadow-inset ui-btn-inline ui-disabled
"
,
JUMP_ADD_CLASS_STR
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-plus ui-shadow-inset ui-btn-inline ui-disabled
"
,
JUMP_UNKNOWN_CLASS_STR
=
"
ui-btn ui-corner-all ui-btn-icon-notext
"
+
"
ui-icon-warning ui-shadow-inset ui-btn-inline ui-disabled
"
;
// Non editable
if
(
!
gadget
.
state
.
editable
)
{
if
((
gadget
.
state
.
value_relative_url
)
&&
(
gadget
.
state
.
allow_jump
))
{
return
displayNonEditableLink
(
gadget
);
}
return
;
return
displayNonEditableText
(
gadget
)
;
}
gadget
.
props
.
index
=
index
;
gadget
.
props
.
addRelationInput
=
options2
.
addRelationInput
;
if
(
field_json
.
default
.
value
)
{
//load non saved value
create_object
=
field_json
.
default
.
create_object
?
field_json
.
default
.
create_object
[
index
]
:
false
;
unknown
=
field_json
.
default
.
jump_unknown
?
field_json
.
default
.
jump_unknown
[
index
]
:
false
;
relation_item_relative_url
=
field_json
.
default
.
relation_item_relative_url
||
[];
uid
=
field_json
.
default
.
uid
;
value
=
field_json
.
default
.
value
[
index
]
||
""
;
}
else
{
create_object
=
field_json
.
create_object
?
field_json
.
create_object
[
index
]
:
false
;
unknown
=
field_json
.
jump_unknown
?
field_json
.
jump_unknown
[
index
]
:
false
;
relation_item_relative_url
=
field_json
.
relation_item_relative_url
;
uid
=
field_json
.
uid
;
value
=
field_json
.
default
[
index
]
||
""
;
}
gadget
.
props
.
jump_url
=
[
relation_item_relative_url
[
index
]];
if
(
relation_item_relative_url
)
{
target_url
=
relation_item_relative_url
[
index
];
if
(
modification_dict
.
hasOwnProperty
(
'
editable
'
))
{
// First display of the input
queue
.
push
(
function
()
{
return
displayEditableLink
(
gadget
,
JUMP_UNKNOWN_CLASS_STR
);
});
}
gadget
.
props
.
query
=
QueryFactory
.
create
(
new
URI
(
field_json
.
query
).
query
(
true
).
query
);
gadget
.
props
.
create_object_type
=
create_object
;
if
(
!
value
&&
target_url
&&
uid
)
{
//return from listbox
not_selected
=
false
;
queue
.
push
(
function
()
{
return
queue
.
push
(
function
()
{
var
plane
=
gadget
.
element
.
querySelector
(
"
a
"
),
ul
=
gadget
.
element
.
querySelector
(
"
.search_ul
"
),
input
=
gadget
.
element
.
querySelector
(
"
input
"
);
ul
.
innerHTML
=
""
;
plane
.
href
=
''
;
if
(
input
.
value
!==
gadget
.
state
.
value_text
)
{
input
.
value
=
gadget
.
state
.
value_text
;
}
// uid is known
// User selected a document from a listbox
if
(
gadget
.
state
.
value_uid
)
{
plane
.
className
=
SEARCHING_CLASS_STR
;
return
gadget
.
jio_allDocs
({
"
query
"
:
Query
.
objectToSearchText
(
new
SimpleQuery
({
key
:
"
catalog.uid
"
,
value
:
uid
,
value
:
gadget
.
state
.
value_
uid
,
limit
:
[
0
,
1
]
})),
"
select_list
"
:
[
field_json
.
catalog_index
]
});
})
.
push
(
function
(
result
)
{
value
=
result
.
data
.
rows
[
0
].
value
[
field_json
.
catalog_index
];
});
}
if
(
target_url
)
{
queue
.
push
(
function
()
{
return
gadget
.
getUrlFor
({
command
:
'
index
'
,
options
:
{
jio_key
:
target_url
}
});
});
}
queue
.
push
(
function
(
href
)
{
var
class_name
,
jump_href
=
'
#
'
;
if
(
create_object
)
{
class_name
=
jump_add
;
}
else
{
if
((
field_json
.
error_text
||
unknown
)
&&
not_selected
)
{
class_name
=
jump_unknown
;
}
else
{
if
(
href
)
{
if
(
field_json
.
allow_jump
)
{
jump_href
=
href
;
class_name
=
jump_on
;
}
else
{
class_name
=
jump_off
;
"
select_list
"
:
[
gadget
.
state
.
catalog_index
]
})
.
push
(
function
(
result
)
{
return
gadget
.
changeState
({
value_text
:
result
.
data
.
rows
[
0
]
.
value
[
gadget
.
state
.
catalog_index
],
value_uid
:
null
});
});
}
// Expected portal type has been selected.
// User want to create a new document
if
(
gadget
.
state
.
value_portal_type
)
{
plane
.
className
=
JUMP_ADD_CLASS_STR
;
return
;
}
// Relative URL is known. Display plane icon
if
(
gadget
.
state
.
value_relative_url
)
{
if
(
gadget
.
state
.
allow_jump
)
{
return
gadget
.
getUrlFor
({
command
:
'
index
'
,
options
:
{
jio_key
:
gadget
.
state
.
value_relative_url
}
}
else
{
class_name
=
jump_off
;
}
})
.
push
(
function
(
url
)
{
plane
.
href
=
url
;
plane
.
className
=
JUMP_ON_CLASS_STR
;
});
}
if
(
modification_dict
.
hasOwnProperty
(
'
value_text
'
))
{
plane
.
className
=
JUMP_UNKNOWN_CLASS_STR
;
}
else
{
plane
.
className
=
JUMP_OFF_CLASS_STR
;
}
return
;
}
return
gadget
.
translateHtml
(
relation_input_template
({
href
:
jump_href
,
create_object
:
create_object
,
readonly
:
field_json
.
editable
?
""
:
"
ui-state-readonly
"
,
input_readonly
:
field_json
.
editable
?
""
:
'
readonly="readonly"
'
,
required
:
field_json
.
required
?
"
required
"
:
""
,
value
:
value
,
title
:
field_json
.
title
,
name
:
field_json
.
key
,
class_name
:
class_name
}));
})
.
push
(
function
(
html
)
{
gadget
.
props
.
element
.
innerHTML
=
html
;
gadget
.
props
.
input
=
gadget
.
props
.
element
.
querySelector
(
"
input
"
);
gadget
.
props
.
new_tag_div
=
gadget
.
props
.
element
.
querySelector
(
"
.new_tag
"
);
gadget
.
props
.
spinner
=
gadget
.
props
.
element
.
querySelector
(
"
a
"
);
gadget
.
props
.
plane
=
gadget
.
props
.
element
.
querySelector
(
"
a
"
);
gadget
.
props
.
input_deferred
.
resolve
();
// No text, user want to delete the content
if
(
!
gadget
.
state
.
value_text
)
{
plane
.
className
=
JUMP_OFF_CLASS_STR
;
return
;
}
// User entered text, but didn't select
// from the list
if
(
!
gadget
.
state
.
has_focus
)
{
plane
.
className
=
JUMP_UNKNOWN_CLASS_STR
;
return
;
}
// User typed some text.
// Propose some documents in a list
plane
.
className
=
SEARCHING_CLASS_STR
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// Wait a bit before launching the catalog query
// as user may still type new characters
return
RSVP
.
delay
(
200
);
})
.
push
(
function
()
{
return
gadget
.
jio_allDocs
({
query
:
Query
.
objectToSearchText
(
new
ComplexQuery
({
operator
:
"
AND
"
,
query_list
:
[
QueryFactory
.
create
(
new
URI
(
gadget
.
state
.
query
).
query
(
true
).
query
),
new
SimpleQuery
({
key
:
gadget
.
state
.
catalog_index
,
value
:
value_text
})
]
})),
limit
:
[
0
,
10
],
select_list
:
[
gadget
.
state
.
catalog_index
]
});
})
.
push
(
function
(
result
)
{
var
list
=
[],
i
,
type
;
if
(
gadget
.
state
.
allow_creation
)
{
type
=
gadget
.
state
.
portal_types
;
}
else
{
type
=
[];
}
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
)
{
list
.
push
({
id
:
result
.
data
.
rows
[
i
].
id
,
value
:
result
.
data
.
rows
[
i
].
value
[
gadget
.
state
.
catalog_index
]
});
}
plane
.
className
=
JUMP_UNKNOWN_CLASS_STR
;
ul
.
innerHTML
=
relation_listview_template
({
list
:
list
,
type
:
type
,
value
:
value_text
});
});
});
return
queue
;
})
.
declareMethod
(
'
getContent
'
,
function
(
options
,
options2
)
{
var
element
=
this
.
props
.
element
.
querySelector
(
'
input
'
),
result
=
{},
tmp
=
{},
field_json
=
this
.
props
.
field_json
;
if
(
!
field_json
.
editable
)
{
return
{};
}
if
(
options
.
format
===
"
erp5
"
)
{
if
(
this
.
props
.
plane
.
className
===
jump_add
)
{
if
(
options2
&&
options2
.
type
===
'
MultiRelationField
'
)
{
result
[
field_json
.
relation_field_id
+
'
_
'
+
this
.
props
.
index
]
=
"
_newContent_
"
+
this
.
props
.
create_object_type
;
}
else
{
result
[
field_json
.
relation_field_id
]
=
"
_newContent_
"
+
this
.
props
.
create_object_type
;
}
}
result
[
element
.
getAttribute
(
'
name
'
)]
=
element
.
value
;
return
result
;
}
tmp
.
value
=
[
element
.
value
];
tmp
.
create_object
=
[
""
];
tmp
.
jump_unknown
=
[
""
];
tmp
.
relation_item_relative_url
=
[
""
];
if
(
this
.
props
.
plane
.
className
===
jump_add
)
{
tmp
.
create_object
=
[
this
.
props
.
create_object_type
];
}
else
{
if
(
this
.
props
.
plane
.
className
===
jump_unknown
)
{
tmp
.
jump_unknown
=
[
true
];
}
else
{
tmp
.
relation_item_relative_url
=
this
.
props
.
jump_url
;
}
.
declareMethod
(
'
getContent
'
,
function
()
{
var
gadget
=
this
,
result
=
{};
if
(
gadget
.
state
.
editable
)
{
result
=
{
value_relative_url
:
gadget
.
state
.
value_relative_url
,
value_text
:
gadget
.
state
.
value_text
,
value_portal_type
:
gadget
.
state
.
value_portal_type
};
}
result
[
element
.
getAttribute
(
'
name
'
)]
=
tmp
;
return
result
;
})
/////////////////////////////////////////////////////////////////
// declared services
/////////////////////////////////////////////////////////////////
.
declareService
(
function
()
{
.
onEvent
(
'
blur
'
,
function
()
{
var
gadget
=
this
,
props
=
gadget
.
props
,
input
,
search_query
,
simple_query
,
field_json
=
props
.
field_json
,
ul
;
function
generateList
(
event
)
{
var
index
=
field_json
.
catalog_index
,
begin_from
=
props
.
begin_from
||
0
,
lines
=
field_json
.
lines
||
10
,
my_value
=
event
.
target
.
value
;
props
.
plane
.
className
=
jump_off
;
props
.
jump_url
=
[];
ul
.
innerHTML
=
""
;
if
(
my_value
===
""
)
{
props
.
spinner
.
className
=
jump_off
;
return
;
}
simple_query
=
new
SimpleQuery
({
key
:
index
,
value
:
my_value
});
props
.
spinner
.
className
=
searching
;
search_query
=
Query
.
objectToSearchText
(
new
ComplexQuery
({
operator
:
"
AND
"
,
query_list
:
[
gadget
.
props
.
query
,
simple_query
]
}));
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
jio_allDocs
({
"
query
"
:
search_query
,
"
limit
"
:
[
begin_from
,
begin_from
+
lines
],
"
select_list
"
:
[
index
]
});
})
.
push
(
function
(
result
)
{
var
list
=
[],
i
,
type
=
field_json
.
allow_creation
?
field_json
.
portal_types
:
[],
html
;
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
)
{
list
.
push
({
id
:
result
.
data
.
rows
[
i
].
id
,
value
:
result
.
data
.
rows
[
i
].
value
[
index
]
});
}
props
.
spinner
.
className
=
jump_off
;
html
=
relation_listview_template
({
list
:
list
,
type
:
type
,
value
:
my_value
});
ul
.
innerHTML
=
html
;
});
}
ul
,
new_state
=
{
has_focus
:
false
};
function
setSelectedElement
(
event
)
{
var
element
=
event
.
target
,
jump_url
=
element
.
getAttribute
(
"
data-relative-url
"
),
create_object_type
=
element
.
getAttribute
(
"
data-create-object
"
),
explore
=
element
.
getAttribute
(
"
data-explore
"
);
ul
.
innerHTML
=
""
;
if
(
jump_url
)
{
props
.
input
.
value
=
element
.
textContent
;
props
.
jump_url
=
[
jump_url
];
return
gadget
.
getUrlFor
({
command
:
'
index
'
,
options
:
{
jio_key
:
jump_url
}
}).
push
(
function
(
url
)
{
if
(
field_json
.
allow_jump
)
{
props
.
plane
.
href
=
url
;
props
.
plane
.
className
=
jump_on
;
}
});
}
if
(
create_object_type
)
{
gadget
.
props
.
create_object_type
=
create_object_type
;
props
.
plane
.
className
=
jump_add
;
return
;
}
if
(
explore
)
{
return
gadget
.
getFormContent
({
format
:
"
json
"
})
.
push
(
function
(
content
)
{
return
gadget
.
redirect
({
command
:
'
index
'
,
options
:
{
page
:
"
relation_search
"
,
url
:
gadget
.
props
.
field_json
.
url
,
extended_search
:
Query
.
objectToSearchText
(
simple_query
),
view
:
gadget
.
props
.
field_json
.
view
,
back_field
:
gadget
.
props
.
field_json
.
key
,
target_index
:
gadget
.
props
.
index
},
form_content
:
content
});
});
}
props
.
plane
.
className
=
jump_unknown
;
if
(
!
gadget
.
state
.
editable
)
{
return
;
}
ul
=
gadget
.
element
.
querySelector
(
"
.search_ul
"
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
input_deferred
.
promise
;
})
.
push
(
function
()
{
input
=
gadget
.
props
.
element
.
querySelector
(
'
input
'
);
ul
=
gadget
.
props
.
element
.
querySelector
(
"
.search_ul
"
);
return
RSVP
.
all
([
loopEventListener
(
input
,
'
input
'
,
false
,
generateList
),
loopEventListener
(
input
,
'
blur
'
,
false
,
function
()
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
any
([
RSVP
.
delay
(
200
),
promiseEventListener
(
ul
,
"
click
"
,
true
)
]);
})
.
push
(
function
(
event
)
{
var
queue
=
new
RSVP
.
Queue
();
if
(
event
)
{
queue
.
push
(
function
()
{
return
setSelectedElement
(
event
);
});
}
if
(
ul
.
innerHTML
)
{
ul
.
innerHTML
=
""
;
props
.
plane
.
className
=
jump_unknown
;
if
(
gadget
.
props
.
addRelationInput
)
{
gadget
.
props
.
addRelationInput
=
false
;
queue
.
push
(
function
()
{
return
gadget
.
addRelationInput
();
});
}
}
return
queue
;
});
})]);
});
})
return
RSVP
.
any
([
.
declareService
(
function
()
{
var
gadget
=
this
;
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
200
);
})
.
push
(
function
()
{
return
gadget
.
changeState
(
new_state
);
}),
function
notifyInvalid
(
evt
)
{
return
gadget
.
notifyInvalid
(
evt
.
target
.
validationMessage
);
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
input_deferred
.
promise
;
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
promiseEventListener
(
ul
,
"
click
"
,
true
);
})
.
push
(
function
(
event
)
{
// Check which 'li' element was clicked
var
li
=
event
.
target
,
data_relative_url
=
li
.
getAttribute
(
"
data-relative-url
"
),
data_portal_type
=
li
.
getAttribute
(
"
data-create-object
"
),
data_explore
=
li
.
getAttribute
(
"
data-explore
"
);
// User want to create a new document
if
(
data_portal_type
)
{
new_state
.
value_portal_type
=
data_portal_type
;
return
gadget
.
changeState
(
new_state
);
}
// User selected an existing document
if
(
data_relative_url
)
{
new_state
.
value_text
=
li
.
textContent
;
new_state
.
value_relative_url
=
data_relative_url
;
return
gadget
.
changeState
(
new_state
);
}
// Go to the search listbox
if
(
data_explore
)
{
return
gadget
.
getFormContent
({
format
:
"
json
"
})
.
push
(
function
(
content
)
{
var
input
=
gadget
.
element
.
querySelector
(
'
input
'
);
return
gadget
.
redirect
({
command
:
'
index
'
,
options
:
{
page
:
"
relation_search
"
,
url
:
gadget
.
state
.
url
,
extended_search
:
Query
.
objectToSearchText
(
new
SimpleQuery
({
key
:
gadget
.
state
.
catalog_index
,
value
:
input
.
value
})
),
view
:
gadget
.
state
.
view
,
back_field
:
gadget
.
state
.
key
,
relation_index
:
gadget
.
state
.
relation_index
},
form_content
:
content
});
});
}
// No idea what has been clicked...
return
gadget
.
changeState
({
has_focus
:
false
});
})
]);
})
.
push
(
function
()
{
// Listen to input change
return
loopEventListener
(
gadget
.
props
.
element
.
querySelector
(
'
input
'
),
'
invalid
'
,
false
,
notifyInvalid
);
return
gadget
.
notifyChange
();
});
},
true
,
false
)
.
declareMethod
(
'
checkValidity
'
,
function
()
{
return
true
;
})
.
declareService
(
function
()
{
////////////////////////////////////
// Check field validity when the value changes
////////////////////////////////////
var
gadget
=
this
;
// XXX Use html5 input
.
onEvent
(
'
invalid
'
,
function
(
evt
)
{
// invalid event does not bubble
return
this
.
notifyInvalid
(
evt
.
target
.
validationMessage
);
},
true
,
false
)
.
onEvent
(
'
change
'
,
function
()
{
return
RSVP
.
all
([
this
.
checkValidity
(),
this
.
notifyChange
()
]);
},
false
,
false
)
function
notifyChange
()
{
return
gadget
.
notifyChange
();
.
onEvent
(
'
input
'
,
function
(
event
)
{
if
(
!
this
.
state
.
editable
)
{
return
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
input_deferred
.
promise
;
})
.
push
(
function
()
{
return
loopEventListener
(
gadget
.
props
.
element
.
querySelector
(
'
input
'
),
'
change
'
,
false
,
notifyChange
);
});
});
}(
window
,
rJS
,
RSVP
,
URI
,
loopEventListener
,
promiseEventListener
,
return
this
.
changeState
({
value_text
:
event
.
target
.
value
,
value_relative_url
:
null
,
value_uid
:
null
,
value_portal_type
:
null
,
has_focus
:
true
});
},
true
,
false
);
}(
window
,
rJS
,
RSVP
,
URI
,
promiseEventListener
,
SimpleQuery
,
ComplexQuery
,
Query
,
QueryFactory
,
Handlebars
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relation_input_js.xml
View file @
ea3b93fb
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
3.41070.65129.47718
</string>
</value>
<value>
<string>
95
4.57692.7289.25070
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>
147
2800801.64
</float>
<float>
147
7583820.22
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relationstringfield_js.js
View file @
ea3b93fb
/*jslint indent: 2, maxerr: 3, nomen: true */
/*jslint indent: 2, maxerr: 3, nomen: true
, maxlen: 80
*/
/*global window, rJS */
(
function
(
window
,
rJS
)
{
"
use strict
"
;
rJS
(
window
)
.
allowPublicAcquisition
(
"
addRelationInput
"
,
function
()
{
return
;
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
,
field_json
=
options
.
field_json
||
{};
return
this
.
getDeclaredGadget
(
"
relation_input
"
)
.
push
(
function
(
gadget
)
{
return
gadget
.
render
(
options
,
{
index
:
0
});
var
render_options
=
{
editable
:
field_json
.
editable
,
query
:
field_json
.
query
,
catalog_index
:
field_json
.
catalog_index
,
allow_jump
:
field_json
.
allow_jump
,
// required: field_json.required,
title
:
field_json
.
title
,
key
:
field_json
.
key
,
view
:
field_json
.
view
,
url
:
field_json
.
url
,
allow_creation
:
field_json
.
allow_creation
,
portal_types
:
field_json
.
portal_types
,
value_relative_url
:
field_json
.
relation_item_relative_url
[
0
],
relation_index
:
0
};
if
(
field_json
.
default
.
hasOwnProperty
(
'
value_text_list
'
))
{
//load non saved value
render_options
.
value_relative_url
=
field_json
.
default
.
value_relative_url_list
[
0
];
render_options
.
value_uid
=
field_json
.
default
.
value_uid_list
[
0
];
render_options
.
value_text
=
field_json
.
default
.
value_text_list
[
0
];
render_options
.
value_portal_type
=
field_json
.
default
.
value_portal_type_list
[
0
];
}
else
{
render_options
.
value_text
=
field_json
.
default
[
0
]
||
""
;
}
return
gadget
.
render
(
render_options
);
})
.
push
(
function
()
{
return
gadget
.
changeState
({
key
:
options
.
field_json
.
key
,
relation_field_id
:
options
.
field_json
.
relation_field_id
});
});
})
.
declareMethod
(
'
getContent
'
,
function
(
options
)
{
var
gadget
=
this
;
return
this
.
getDeclaredGadget
(
"
relation_input
"
)
.
push
(
function
(
gadget
)
{
return
gadget
.
getContent
(
options
);
.
push
(
function
(
input_gadget
)
{
return
input_gadget
.
getContent
();
})
.
push
(
function
(
input_result
)
{
var
result
=
{};
if
(
!
input_result
.
hasOwnProperty
(
'
value_text
'
))
{
return
result
;
}
if
(
options
.
format
===
"
erp5
"
)
{
if
(
input_result
.
value_portal_type
)
{
result
[
gadget
.
state
.
relation_field_id
]
=
"
_newContent_
"
+
input_result
.
value_portal_type
;
}
result
[
gadget
.
state
.
key
]
=
input_result
.
value_text
;
}
else
{
result
[
gadget
.
state
.
key
]
=
{
value_text_list
:
[
input_result
.
value_text
],
value_relative_url_list
:
[
input_result
.
value_relative_url
],
value_portal_type_list
:
[
input_result
.
value_portal_type
],
value_uid_list
:
[
undefined
]
};
}
return
result
;
});
});
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_relationstringfield_js.xml
View file @
ea3b93fb
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.
45675.44850.5345
2
</string>
</value>
<value>
<string>
954.
57675.64427.5246
2
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1477
037965.54
</float>
<float>
1477
582815.99
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
View file @
ea3b93fb
...
...
@@ -446,7 +446,7 @@
function
execHistoryPreviousCommand
(
gadget
,
previous_options
,
load_options
)
{
var
history
=
previous_options
.
history
,
jio_key
=
previous_options
.
jio_key
,
target_index
=
previous_options
.
target
_index
,
relation_index
=
previous_options
.
relation
_index
,
field
=
previous_options
.
back_field
,
queue
=
new
RSVP
.
Queue
(),
previous_id
;
...
...
@@ -473,9 +473,9 @@
if
(
results
)
{
results
=
JSON
.
parse
(
results
.
target
.
result
);
if
(
load_options
.
uid
)
{
results
[
field
].
value
[
target
_index
]
=
""
;
results
[
field
].
relation_item_relative_url
[
target
_index
]
=
load_options
.
jio_key
;
results
[
field
].
uid
=
load_options
.
uid
;
results
[
field
].
value
_text_list
[
relation
_index
]
=
""
;
results
[
field
].
value_relative_url_list
[
relation
_index
]
=
load_options
.
jio_key
;
results
[
field
].
value_uid_list
[
relation_index
]
=
load_options
.
uid
;
}
gadget
.
props
.
form_content
=
results
;
}
...
...
@@ -491,8 +491,8 @@
return
gadget
.
props
.
jio_gadget
.
get
(
history
.
options_id
);
})
.
push
(
function
(
result
)
{
var
result_list
=
[
result
,
previous_id
]
;
var
options
=
result_list
[
0
].
data
,
var
result_list
=
[
result
,
previous_id
]
,
options
=
result_list
[
0
].
data
,
next_jio_key
=
options
.
jio_key
;
delete
options
.
jio_key
;
return
addNavigationHistoryAndDisplay
(
gadget
,
next_jio_key
,
options
);
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
View file @
ea3b93fb
...
...
@@ -232,7 +232,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.
47260.43395.7014
</string>
</value>
<value>
<string>
954.
57620.63396.46779
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>
147
6957907.92
</float>
<float>
147
7580291.06
</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