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
Sebastien Robin
erp5
Commits
100bde26
Commit
100bde26
authored
Oct 04, 2016
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
officejs task app: implement saving of dates changes in the planning
parent
8cd4d1b3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
32 deletions
+119
-32
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_planning_html.html
...m/web_page_module/gadget_officejs_page_planning_html.html
+7
-1
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_planning_js.js
...eItem/web_page_module/gadget_officejs_page_planning_js.js
+60
-25
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_widget_planning_js.js
...tem/web_page_module/gadget_officejs_widget_planning_js.js
+52
-6
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_planning_html.html
View file @
100bde26
...
...
@@ -15,9 +15,15 @@
<body>
<div
class=
"planning-error-message"
></div>
<form
class=
"view-web-page-form"
>
<div
class=
'document-content'
></div>
</div>
<button
type=
"submit"
data-i18n=
"Save"
style=
"display:none;"
>
Save
</button>
</div>
</form>
</body>
</html>
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_planning_js.js
View file @
100bde26
/*globals window, RSVP, rJS, console*/
/*globals window, RSVP, rJS,
loopEventListener,
console*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(
function
(
window
,
RSVP
,
rJS
)
{
"
use strict
"
;
var
PLANNING_WIDGET_GADGET_URL
=
"
planning/
"
;
function
saveContent
(
gadget
,
submit_event
)
{
console
.
log
(
"
Going to save the content of the planning
"
);
return
gadget
.
property_dict
.
planning_widget
.
saveContent
();
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
prop
s
=
{};
g
.
prop
erty_dict
=
{};
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
prop
s
.
element
=
element
;
g
.
prop
s
.
deferred
=
RSVP
.
defer
();
g
.
prop
erty_dict
.
element
=
element
;
g
.
prop
erty_dict
.
deferred
=
RSVP
.
defer
();
});
})
.
ready
(
function
(
g
)
{
...
...
@@ -24,7 +31,7 @@
]);
})
.
push
(
function
(
result_list
)
{
g
.
prop
s
.
translation_dict
=
{
g
.
prop
erty_dict
.
translation_dict
=
{
"
validated
"
:
result_list
[
0
],
"
invalidated
"
:
result_list
[
1
],
"
Not synced!
"
:
result_list
[
2
],
...
...
@@ -47,10 +54,10 @@
// XXX jIO does not create UUID with module inside
if
(
result
.
data
.
rows
[
i
].
id
.
indexOf
(
"
module
"
)
===
-
1
)
{
result
.
data
.
rows
[
i
].
value
.
state
=
gadget
.
prop
s
.
translation_dict
[
"
Not synced!
"
];
gadget
.
prop
erty_dict
.
translation_dict
[
"
Not synced!
"
];
}
else
{
result
.
data
.
rows
[
i
].
value
.
state
=
gadget
.
prop
s
.
translation_dict
[
gadget
.
prop
erty_dict
.
translation_dict
[
result
.
data
.
rows
[
i
].
value
.
local_state
||
"
Waiting for approval
"
];
...
...
@@ -59,6 +66,15 @@
return
result
;
});
})
.
allowPublicAcquisition
(
'
triggerSubmit
'
,
function
()
{
return
this
.
property_dict
.
element
.
querySelector
(
'
button
'
).
click
();
})
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
return
this
.
property_dict
.
element
.
querySelector
(
'
button
'
).
click
();
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
...
...
@@ -69,18 +85,18 @@
]);
})
.
push
(
function
(
answer_list
)
{
gadget
.
prop
s
.
portal_type
=
answer_list
[
0
];
gadget
.
prop
s
.
document_title_plural
=
answer_list
[
1
];
gadget
.
prop
erty_dict
.
portal_type
=
answer_list
[
0
];
gadget
.
prop
erty_dict
.
document_title_plural
=
answer_list
[
1
];
return
gadget
.
getUrlFor
({
page
:
"
add_document
"
});
})
.
push
(
function
(
url
)
{
return
gadget
.
updateHeader
({
title
:
gadget
.
prop
s
.
document_title_plural
,
add_url
:
url
title
:
gadget
.
prop
erty_dict
.
document_title_plural
,
save_action
:
true
});
})
.
push
(
function
()
{
return
gadget
.
prop
s
.
deferred
.
resolve
();
return
gadget
.
prop
erty_dict
.
deferred
.
resolve
();
});
})
...
...
@@ -93,7 +109,7 @@
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
prop
s
.
deferred
.
promise
;
return
gadget
.
prop
erty_dict
.
deferred
.
promise
;
})
.
push
(
function
()
{
return
gadget
.
declareGadget
(
...
...
@@ -101,18 +117,19 @@
{
scope
:
"
planning
"
,
sandbox
:
"
iframe
"
,
element
:
gadget
.
prop
s
.
element
.
querySelector
(
"
.document-content
"
)
element
:
gadget
.
prop
erty_dict
.
element
.
querySelector
(
"
.document-content
"
)
}
);
})
.
push
(
function
(
planning_
ga
dget
)
{
var
iframe
=
gadget
.
prop
s
.
element
.
querySelector
(
'
iframe
'
);
.
push
(
function
(
planning_
wi
dget
)
{
var
iframe
=
gadget
.
prop
erty_dict
.
element
.
querySelector
(
'
iframe
'
);
iframe
.
setAttribute
(
'
style
'
,
'
width:100%; border: 0 none; height: 600px
'
);
text_gadget
=
planning_gadget
;
return
planning_gadget
.
render
({
text_gadget
=
planning_widget
;
gadget
.
property_dict
.
planning_widget
=
planning_widget
;
return
planning_widget
.
render
({
search_page
:
'
planning
'
,
mapping
:
{
title
:
'
title
'
,
start
:
'
start_date
'
,
...
...
@@ -137,7 +154,7 @@
title
:
'
Modification Date
'
}],
query
:
{
query
:
'
portal_type:("
'
+
gadget
.
prop
s
.
portal_type
+
'
")
'
,
query
:
'
portal_type:("
'
+
gadget
.
prop
erty_dict
.
portal_type
+
'
")
'
,
select_list
:
[
'
title
'
,
'
reference
'
,
'
start_date
'
,
'
description
'
,
'
stop_date
'
,
'
modification_date
'
],
limit
:
[
0
,
30
]
...
...
@@ -150,9 +167,9 @@
.
fail
(
function
(
error
)
{
console
.
log
(
"
LOADing error, error
"
,
error
);
var
display_error_element
;
if
(
error
.
message
.
startsWith
(
"
Timeout
"
)
===
true
)
{
if
(
(
error
.
message
||
''
)
.
startsWith
(
"
Timeout
"
)
===
true
)
{
display_error_element
=
gadget
.
prop
s
.
element
.
querySelector
(
gadget
.
prop
erty_dict
.
element
.
querySelector
(
"
.planning-error-message
"
);
display_error_element
.
innerHTML
=
...
...
@@ -165,9 +182,27 @@
throw
error
;
}
});
});
}(
window
,
RSVP
,
rJS
));
})
/////////////////////////////////////////
// Form submit
/////////////////////////////////////////
.
declareService
(
function
()
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
property_dict
.
deferred
.
promise
;
})
.
push
(
function
()
{
return
loopEventListener
(
gadget
.
property_dict
.
element
.
querySelector
(
'
form
'
),
'
submit
'
,
true
,
function
(
event
)
{
return
saveContent
(
gadget
,
event
);
}
);
});
});
}(
window
,
RSVP
,
rJS
,
loopEventListener
));
\ No newline at end of file
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_widget_planning_js.js
View file @
100bde26
...
...
@@ -8,6 +8,20 @@
/////////////////////////////////////////////////////////////////
var
gadget_klass
=
rJS
(
window
);
function
toDateString
(
date
)
{
var
date_string
=
""
+
date
.
getUTCFullYear
()
+
"
-
"
,
month
=
date
.
getUTCMonth
()
+
1
,
day
=
date
.
getUTCDate
();
if
(
month
<
10
)
{
date_string
+=
"
0
"
;
}
date_string
+=
month
+
"
-
"
;
if
(
day
<
10
)
{
date_string
+=
"
0
"
;
}
date_string
+=
day
;
return
date_string
;
}
/////////////////////////////////////////////////////////////////
// some methods
/////////////////////////////////////////////////////////////////
...
...
@@ -38,6 +52,7 @@
// acquired methods
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
translate
"
,
"
translate
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
...
...
@@ -45,6 +60,21 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
saveContent
'
,
function
(
option_dict
)
{
var
gadget
=
this
,
id
,
promise_list
=
[],
task
,
now
=
new
Date
().
toISOString
();
console
.
log
(
"
going to save from widget
"
,
gadget
.
property_dict
.
updated_task
);
Object
.
getOwnPropertyNames
(
gadget
.
property_dict
.
updated_task
).
forEach
(
function
(
value
,
index
,
array
)
{
task
=
gadget
.
property_dict
.
updated_task
[
value
];
console
.
log
(
"
going to save document
"
,
value
,
task
);
task
.
parent_relative_url
=
"
task_module
"
;
task
.
portal_type
=
"
Task
"
;
task
.
modification_date
=
now
;
promise_list
.
push
(
gadget
.
jio_put
(
value
,
gadget
.
property_dict
.
updated_task
[
value
]));
});
return
RSVP
.
all
(
promise_list
);
})
.
declareMethod
(
'
render
'
,
function
(
option_dict
)
{
var
gadget
=
this
,
content
=
''
,
...
...
@@ -80,6 +110,7 @@
cell_list
,
item_list
=
[],
item
,
item_id
,
task
,
i_len
,
i
,
...
...
@@ -87,15 +118,28 @@
j
,
link
,
container
,
item_dict
=
{},
timeline
,
task
,
items
=
new
vis
.
DataSet
({
type
:
{
start
:
'
ISODate
'
,
end
:
'
ISODate
'
}
//
type: { start: 'ISODate', end: 'ISODate' }
});
gadget
.
property_dict
.
updated_task
=
{};
// log changes to the console
items
.
on
(
'
*
'
,
function
(
event
,
properties
)
{
console
.
log
(
event
,
properties
.
items
);
if
(
event
===
"
update
"
)
{
console
.
log
(
"
we have an update event
"
);
item
=
properties
.
data
[
0
];
task
=
item_dict
[
item
.
id
];
console
.
log
(
"
this task is updated
"
,
task
);
task
[
option_dict
.
mapping
.
start
]
=
toDateString
(
item
.
start
);
task
[
option_dict
.
mapping
.
stop
]
=
toDateString
(
item
.
end
);
gadget
.
property_dict
.
updated_task
[
item
.
id
]
=
task
;
}
//task = {};
//return gadget.jio_put();
});
// planning-widget
...
...
@@ -126,11 +170,13 @@
item
=
{};
link
=
link_list
[
j
];
task
=
all_docs_result
.
data
.
rows
[
j
].
value
;
item
.
id
=
j
;
item
.
content
=
task
.
title
;
item
.
start
=
task
.
start_date
;
item
.
end
=
task
.
stop_date
;
item_id
=
all_docs_result
.
data
.
rows
[
j
].
id
;
item
.
id
=
item_id
;
item
.
content
=
task
[
option_dict
.
mapping
.
title
];
item
.
start
=
task
[
option_dict
.
mapping
.
start
];
item
.
end
=
task
[
option_dict
.
mapping
.
stop
];
item_list
.
push
(
item
);
item_dict
[
item_id
]
=
task
;
}
console
.
log
(
"
item_list
"
,
item_list
);
...
...
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