Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pixel Humain
survey
Commits
4729bf00
Commit
4729bf00
authored
Mar 10, 2020
by
Raph El
Browse files
Merge branch 'qa' of
https://gitlab.adullact.net/pixelhumain/survey
into qa
parents
82790fc9
dae266d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
views/tpls/forms/cplx/answers.php
View file @
4729bf00
...
...
@@ -67,7 +67,8 @@
if
(
!
isset
(
$t
[
"done"
])
||
$t
[
"done"
]
==
"0"
)
{
$todo
++
;
foreach
(
explode
(
","
,
$t
[
"who"
])
as
$whoix
=>
$who
)
{
$whos
=
(
is_array
(
$t
[
"who"
]))
?
$t
[
"who"
]
:
explode
(
","
,
$t
[
"who"
]);
foreach
(
$whos
as
$whoix
=>
$who
)
{
if
(
!
isset
(
$tasksPerson
[
$who
]
)
)
$tasksPerson
[
$who
]
=
[];
$tasksPerson
[
$who
][]
=
$t
[
"what"
];
...
...
views/tpls/forms/cplx/suiviFromBudget.php
View file @
4729bf00
...
...
@@ -195,7 +195,7 @@ $properties = [
$valbl
=
count
(
$a
[
"todo"
]
);
$totalTodos
+=
count
(
$a
[
"todo"
]);
foreach
(
$a
[
"todo"
]
as
$tix
=>
$do
)
{
if
(
$do
[
"done"
]
==
"1"
)
if
(
isset
(
$do
[
"done"
])
&&
$do
[
"done"
]
==
"1"
)
$todoDone
++
;
else
$todo
++
;
...
...
@@ -474,44 +474,50 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Suivi des d
$members
=
PHDB
::
find
(
Person
::
COLLECTION
,
[
"_id"
=>
[
'$in'
=>
$uids
]
]
,
[
"name"
,
"username"
]
);
?>
<!-- <textarea id="new-todo-item" class="new-todo-item col-xs-5" name="todo" placeholder="Quoi"></textarea> -->
<div
class=
"col-xs-8"
>
<label
for=
"new-todo-item"
>
Choses à faire
</label>
<input
type=
"text"
id=
"new-todo-item"
class=
"new-todo-item col-xs-12"
name=
"todo"
placeholder=
"Quoi"
/>
<div
class=
"col-xs-12"
>
<div
class=
"col-xs-8"
>
<label
for=
"new-todo-item"
>
Choses à faire
</label>
<input
type=
"text"
id=
"new-todo-item"
class=
"new-todo-item col-xs-12"
name=
"todo"
placeholder=
"Quoi"
/>
</div>
<div
class=
"col-xs-4"
>
<label
for=
"new-todo-item-price"
>
<i
class=
'fa fa-money'
></i>
Cout de cette tache
</label>
<input
type=
"text"
id=
"new-todo-item-price"
class=
"new-todo-item-price col-xs-12"
name=
"price"
placeholder=
"Pour combien"
/>
<!-- <select id="votes" style="width:100%;">
<option> VOTEZ pour cette partie </option>
<?php
foreach
([
0
,
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
]
as
$v
=>
$f
)
{
if
(
$f
==
0
)
$lbl
=
"Je ne suis pas pour!"
;
else
$lbl
=
"Je suis pour à "
.
$f
.
"%"
;
echo
"<option value='"
.
$f
.
"'>"
.
$lbl
.
"</option>"
;
}
?>
</select> -->
</div>
</div>
<div
class=
"col-xs-4"
>
<label
for=
"new-todo-item-price"
>
<i
class=
'fa fa-money'
></i>
Cout de cette tache
</label>
<input
type=
"text"
id=
"new-todo-item-price"
class=
"new-todo-item-price col-xs-12"
name=
"price"
placeholder=
"Pour combien"
/>
<!-- <select id="votes" style="width:100%;">
<option> VOTEZ pour cette partie </option>
<?php
foreach
([
0
,
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
]
as
$v
=>
$f
)
{
if
(
$f
==
0
)
$lbl
=
"Je ne suis pas pour!"
;
else
$lbl
=
"Je suis pour à "
.
$f
.
"%"
;
echo
"<option value='"
.
$f
.
"'>"
.
$lbl
.
"</option>"
;
}
?>
</select> -->
<div
class=
"col-xs-12 margin-top-10"
>
<div
class=
"col-xs-6"
>
<label
for=
"new-todo-item-date"
>
<i
class=
'fa fa-calendar'
></i>
Date de fin estimé :
</label>
<input
type=
"date"
id=
"new-todo-item-date"
class=
"new-todo-item-date col-xs-12"
name=
"when"
placeholder=
"Pour quand"
/>
</div>
<div
class=
"col-xs-6"
>
<label
for=
"new-todo-item-who"
>
<i
class=
'fa fa-user'
></i>
Personne(s) qui réalisera cette tache :
</label>
<select
id=
"new-todo-item-who"
class=
"new-todo-item-who col-xs-12"
multiple
>
<?php
foreach
(
$members
as
$id
=>
$p
)
{
$selected
=
(
$id
==
Yii
::
app
()
->
session
[
"userId"
]
)
?
"selected"
:
""
;
echo
"<option value='"
.
$p
[
"username"
]
.
"' data-id='"
.
$id
.
"' "
.
$selected
.
" >"
.
$p
[
"name"
]
.
"</option>"
;
}
?>
</select>
</div>
</div>
<div
class=
"col-xs-6"
>
<label
for=
"new-todo-item-date"
>
<i
class=
'fa fa-calendar'
></i>
Date de fin estimé :
</label>
<input
type=
"date"
id=
"new-todo-item-date"
class=
"new-todo-item-date col-xs-12"
name=
"when"
placeholder=
"Pour quand"
/>
<div
class=
"col-xs-12 margin-top-10 text-center"
>
<a
id=
"add-todo-item"
class=
"btn btn-primary"
href=
"javascript:;"
><i
class=
'fa fa-plus'
></i>
Ajouter
</a>
</div>
<div
class=
"col-xs-6"
>
<label
for=
"new-todo-item-who"
>
<i
class=
'fa fa-user'
></i>
Personne(s) qui réalisera cette tache :
</label>
<select
id=
"new-todo-item-who"
class=
"new-todo-item-who col-xs-12"
multiple
>
<?php
foreach
(
$members
as
$id
=>
$p
)
{
$selected
=
(
$id
==
Yii
::
app
()
->
session
[
"userId"
]
)
?
"selected"
:
""
;
echo
"<option value='"
.
$p
[
"username"
]
.
"' data-id='"
.
$id
.
"' "
.
$selected
.
" >"
.
$p
[
"name"
]
.
"</option>"
;
}
?>
</select>
</div>
</form>
<form
id=
"form-todo-list"
>
<ul
id=
"todo-list"
class=
"col-xs-12 todo-list"
></ul>
<ul
id=
"todo-list"
class=
"
margin-top-20
col-xs-12 todo-list"
style=
"border: 1px solid black"
></ul>
</form>
</div>
...
...
@@ -845,6 +851,7 @@ $(document).ready(function() {
tplCtx.id = $(this).data(
"
id
"
);
tplCtx.form = $(this).data(
"
form
"
);
mylog.log(
"
btnTodo
open
"
,tplCtx);
tplCtx.editTaskpos = null;
prioModal = bootbox.dialog({
message: $(
"
.
form
-
todo
"
).html(),
...
...
@@ -862,33 +869,17 @@ $(document).ready(function() {
if( notNull(formInputs [tplCtx.form]) )
tplCtx.path =
"
answers
.
"
+tplCtx.form;
tplCtx.path = tplCtx.path+
"
.
"
+tplCtx.budgetpath+
"
.
"
+tplCtx.pos+
"
.
todo
"
;
tplCtx.value = [];
tplCtx.path = tplCtx.path+
"
.
"
+tplCtx.budgetpath+
"
.
"
+tplCtx.pos+
"
.
todo
"
;
tplCtx.value = answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo;
var todoDone = 0;
//todoArray au lieu de géré avec des li
//avoir un array avec des objets + render
$('.bootbox #todo-list').find('li').each(function() {
var t = {
what : $(this).find(
"
.
liText
"
).text(),
price : $(this).data(
"
price
"
),
uid : $(this).data(
"
uid
"
),
who : $(this).data(
"
who
"
),
when : $(this).data(
"
when
"
),
created : $(this).data(
"
created
"
),
done : ( $(this).find(
"
.
todo
-
item
-
done
"
).is(
"
:
checked
"
) ) ?
"
1
"
:
"
0
"
}
if( $(this).find(
"
.
todo
-
item
-
done
"
).is(
"
:
checked
"
) )
todoDone++;
tplCtx.value.push(t);
});
answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo = tplCtx.value;
$(
"
#
btnTodo
"
+tplCtx.pos).html(todoDone+
"
/
"
+tplCtx.value.length);
$(
"
#
todoProgress
"
+tplCtx.pos).css(
"
width
"
,Math.floor(todoDone*100/tplCtx.value.length));
$.each(tplCtx.value, function(ix,todo) {
if(parseInt(todo.done) == 1)
todoDone++;
})
$(
"
#
btnTodo
"
+tplCtx.pos).html( todoDone+
"
/
"
+tplCtx.value.length );
$(
"
#
todoProgress
"
+tplCtx.pos).css(
"
width
"
,Math.floor(todoDone*100/tplCtx.value.length));
$(
"
#
todoPerc
"
+tplCtx.pos).html(Math.floor(todoDone*100/tplCtx.value.length)+
"
%
"
);
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log(
"
btnPay
save
"
,tplCtx);
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,
"
workTodo
"
,userId,closePrioModalRel);
...
...
@@ -904,31 +895,19 @@ $(document).ready(function() {
onEscape: closePrioModal
});
prioModal.on('shown.bs.modal', function (e) {
prioModal.css({'background-color': '#000'} );
$(
"
.
bootbox
#
add
-
todo
-
item
"
).off().on('click', function(e){
e.preventDefault();
addTodoItem()
listObj.
addTodoItem()
});
$(
"
.
bootbox
#
new
-
todo
-
item
,
.
bootbox
#
new
-
todo
-
item
-
when
,.
bootbox
#
new
-
todo
-
item
-
who
,.
bootbox
#
new
-
todo
-
item
-
price
"
).off().on('keypress', function(e){
var keycode;
if (window.event) {keycode = window.event.keyCode;e=event;}
else if (e){ keycode = e.which;}
if( keycode==
"
13
"
)
addTodoItem();
listObj.
addTodoItem();
});
// $(
"
.
bootbox
#
new
-
todo
-
item
-
who
"
).bind('keypress',function(e) {
// if(e.which === 13)
// addTodoItem();
// });
$(
"
.
bootbox
#
todo
-
list
"
).on('click', '.todo-item-delete', function(e){
var item = this;
deleteTodoItem(e, item)
})
$(
"
.
bootbox
#
todo
-
list
"
).on('click', '.todo-item-edit', function(e){
var item = this;
editTodoItem(e, item)
})
$(
"
.
bootbox
.
todo
-
item
-
done
"
).on('click', completeTodoItem);
todoPath =
"
answerObj
.
answers
.
"
;
if( notNull(formInputs [tplCtx.form]) )
...
...
@@ -940,9 +919,11 @@ $(document).ready(function() {
var todos = eval( todoPath );
mylog.log(
"
build
todos
"
,todos);
$.each(todos, function(ix,todo) {
buildTodo(
ix, todo.what,todo.price, ( ( parseInt(todo.done) ) ?
"
checked
"
:
""
),todo.uid,todo.who,todo.created,todo.when
);
listObj.
buildTodo(
todo, ix
);
})
}
listObj.btnInit();
})
prioModal.modal(
"
show
"
);
});
...
...
@@ -950,81 +931,190 @@ $(document).ready(function() {
});
function addTodoItem() {
var today = new Date();
today = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
var when = ($(
"
.
bootbox
#
new
-
todo
-
item
-
date
"
).val()) ? $(
"
.
bootbox
#
new
-
todo
-
item
-
date
"
).val() :
""
;
var price = ($(
"
.
bootbox
#
new
-
todo
-
item
-
price
"
).val()) ? $(
"
.
bootbox
#
new
-
todo
-
item
-
price
"
).val() :
""
;
var who = ($(
"
.
bootbox
#
new
-
todo
-
item
-
who
"
).val()) ? $(
"
.
bootbox
#
new
-
todo
-
item
-
who
"
).val() : userConnected.name ;
buildTodo(editingItem,$(
"
.
bootbox
#
new
-
todo
-
item
"
).val(),price,
""
,userId, who, today,when);
$(
"
.
bootbox
#
new
-
todo
-
item
,
.
bootbox
#
new
-
todo
-
item
-
when
"
).val(
""
);
}
//todoArray au lieu de géré avec des li
//avoir un array avec des objets + render
function buildTodo(pos,todoItem,price,checked,uid,who,created,when){
if(!notNull( uid)) uid = userId;
if(!notNull( who)) who = userConnected.name;
whoids =
""
;
if(!notNull(price)) price =
""
;
if(typeof when ==
"
undefined
"
|| when ==
""
)
when =
""
;
if(notNull( created)) {
var listObj = {
addTodoItem : function () {
var today = new Date();
created = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
}
today = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
var todo = {
what : $(
"
.
bootbox
#
new
-
todo
-
item
"
).val(),
uid : userId,
who : userConnected.username,
created : today
};
if ( $(
"
.
bootbox
#
new
-
todo
-
item
-
date
"
).val() )
todo.when = $(
"
.
bootbox
#
new
-
todo
-
item
-
date
"
).val();
if( $(
"
.
bootbox
#
new
-
todo
-
item
-
price
"
).val() )
todo.price = $(
"
.
bootbox
#
new
-
todo
-
item
-
price
"
).val();
if($(
"
.
bootbox
#
new
-
todo
-
item
-
who
"
).val())
todo.who = $(
"
.
bootbox
#
new
-
todo
-
item
-
who
"
).val() ;
mylog.log(
"
addTodoItem
"
,todo, tplCtx.editTaskpos);
listObj.buildTodo(todo, tplCtx.editTaskpos);
listObj.btnInit();
if(pos === null)
pos = $(
"
.
liTodo
"
).length - 1;
str =
"
<
div
class
=
'
col-xs-1
'
>
"
+
"
<
a
class
=
'
btn btn-xs btn-danger todo-item-delete
'
href
=
'
javascript:;
'
><
i
class
=
'
fa fa-times-rectangle
'
><
/i></
a
>
"
+
"
<
a
class
=
'
btn btn-xs btn-primary todo-item-edit
'
href
=
'
javascript:;
'
><
i
class
=
'
fa fa-pencil
'
><
/i></
a
>
"
+
"
<
/div>"
+
"
<div class='col-xs-1'><input type='checkbox' name='todo-item-done' class='todo-item-done' value='
"
+
todoItem
+
"
'
"
+
checked
+
"
/></div>
"
+
"
<div class='col-xs-10 liText' >
"
+
todoItem
+
"
</div>
"
+
"
<div class='col-xs-12' >
"
+
"
<div class='col-xs-2'></div>
"
+
"
<div class='col-xs-2' style='font-size:0.8em'> <i class='fa fa-money'></i>
"
+
price
+
"
</div>
"
+
"
<div class='col-xs-3' style='font-size:0.8em'> <i class='fa fa-calendar'></i>
"
+
when
+
"
</div>
"
+
"
<div class='col-xs-5' style='font-size:0.8em' > <i class='fa fa-user'></i>
"
+
who
+
"
</div>
"
+
"
</div>
"
;
if
(
editingItem
){
$
(
"
.liText
"
).
eq
(
pos
).
parent
().
html
(
str
);
editingItem
=
null
;
}
else
$
(
"
.bootbox #todo-list
"
).
append
(
"
<li class='liTodo col-xs-12' data-pos='
"
+
pos
+
"
' data-uid='
"
+
uid
+
"
' data-created='
"
+
created
+
"
' data-who='
"
+
who
+
"
' data-whoids='
"
+
whoids
+
"
' data-when='
"
+
when
+
"
' data-price='
"
+
price
+
"
' >
"
+
str
+
"
</li>
"
);
}
if( notNull(tplCtx.form) && notNull(formInputs [tplCtx.form]) ){
if( typeof answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo ==
"
undefined
"
)
answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo = [];
answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo.push(todo);
}
else if( notNull(tplCtx.budgetpath) ) {
if( typeof answerObj.answers[tplCtx.budgetpath][tplCtx.pos].todo ==
"
undefined
"
)
answerObj.answers[tplCtx.form][tplCtx.budgetpath][tplCtx.pos].todo = [];
answerObj.answers[tplCtx.budgetpath][tplCtx.pos].todo.push(todo);
}
function
deleteTodoItem
(
e
,
item
)
{
e
.
preventDefault
();
$
(
item
).
parent
().
parent
().
fadeOut
(
'
slow
'
,
function
()
{
$
(
item
).
parent
().
parent
().
remove
();
});
}
var
editingItem
=
null
;
function
editTodoItem
(
e
,
item
)
{
e
.
preventDefault
();
editingItem
=
$
(
item
).
parent
().
parent
().
data
(
"
pos
"
);
$
(
"
.bootbox #new-todo-item
"
).
val
(
$
(
item
).
parent
().
parent
().
find
(
"
.liText
"
).
text
()
);
$
(
"
.bootbox #new-todo-item-date
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
when
"
)
);
$
(
"
.bootbox #new-todo-item-price
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
price
"
)
);
$
(
"
.bootbox #new-todo-item-who option
"
).
prop
(
"
selected
"
,
false
)
if
(
$
(
item
).
parent
().
parent
().
data
(
"
who
"
).
indexOf
(
"
,
"
)){
whosT
=
$
(
item
).
parent
().
parent
().
data
(
"
who
"
).
split
(
"
,
"
);
$
.
each
(
whosT
,
function
(
i
,
u
){
$
(
"
.bootbox #new-todo-item-who option[value='
"
+
u
+
"
']
"
).
prop
(
"
selected
"
,
true
)
})
}
else
$
(
"
.bootbox #new-todo-item-who
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
who
"
)
);
}
$(
"
.
bootbox
#
new
-
todo
-
item
,
.
bootbox
#
new
-
todo
-
item
-
date
,
.
bootbox
#
new
-
todo
-
item
-
price
"
).val(
""
);
},
//todoArray au lieu de géré avec des li
//avoir un array avec des objets + render
buildTodo : function (todoObj, pos) {
mylog.log(
"
buildTodo
"
,todoObj, pos);
var uid = (notNull( todoObj.uid)) ? todoObj.uid : userId;
var who =
""
;
if(!notNull( todoObj.who)) who = userConnected.name;
else if(typeof todoObj.who ==
"
object
"
){
$.each(todoObj.who,function(i,w) {
if( who!=
""
) who +=
"
,
"
;
who += w; })
} else
who = todoObj.who;
var whoids =
""
;
var price = (notNull(todoObj.price)) ? todoObj.price :
""
;
var when = (typeof todoObj.when ==
"
undefined
"
|| todoObj.when ==
""
) ?
""
: todoObj.when;
if(!notNull( todoObj.created)) {
var today = new Date();
var created = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
}
var doneDate = (notNull( todoObj.doneDate)) ?
"
<
br
/><
i
class
=
'
fa fa-calendar-check-o
'
><
/i> "+todoObj.doneDate : ""
;
if
(
pos
===
null
)
pos
=
$
(
"
.liTodo
"
).
length
;
var
checked
=
(
(
parseInt
(
todoObj
.
done
)
)
?
"
checked
"
:
""
);
str
=
"
<div class='col-xs-1'>
"
+
"
<a class='btn btn-xs btn-danger todo-item-delete' href='javascript:;'><i class='fa fa-times-rectangle'></i></a>
"
+
"
<a class='btn btn-xs btn-primary todo-item-edit' href='javascript:;'><i class='fa fa-pencil'></i></a>
"
+
"
</div>
"
+
"
<div class='col-xs-1'><input type='checkbox' name='todo-item-done' class='todo-item-done'
"
+
checked
+
"
/></div>
"
+
"
<div class='col-xs-10 liText' >
"
+
todoObj
.
what
+
"
</div>
"
+
"
<div class='col-xs-12' >
"
+
"
<div class='col-xs-2'></div>
"
+
"
<div class='col-xs-2' style='font-size:0.8em'> <i class='fa fa-money'></i>
"
+
price
+
"
</div>
"
+
"
<div class='col-xs-3' style='font-size:0.8em'> <i class='fa fa-calendar-o'></i>
"
+
when
+
doneDate
+
"
</div>
"
+
"
<div class='col-xs-5' style='font-size:0.8em' > <i class='fa fa-user'></i>
"
+
who
+
"
</div>
"
+
"
</div>
"
;
if
(
tplCtx
.
editTaskpos
!=
null
){
$
(
"
.liText
"
).
eq
(
pos
).
parent
().
html
(
str
);
delete
tplCtx
.
editTaskpos
;
}
else
$
(
"
.bootbox #todo-list
"
).
append
(
"
<li class='liTodo col-xs-12' data-pos='
"
+
pos
+
"
' data-uid='
"
+
uid
+
"
' data-created='
"
+
created
+
"
' data-who='
"
+
who
+
"
' data-whoids='
"
+
whoids
+
"
' data-when='
"
+
when
+
"
' data-price='
"
+
price
+
"
' >
"
+
str
+
"
</li>
"
);
},
deleteTodoItem
:
function
(
e
,
item
)
{
e
.
preventDefault
();
var
taskPos
=
$
(
item
).
parent
().
parent
().
data
(
"
pos
"
);
$
(
item
).
parent
().
parent
().
fadeOut
(
'
slow
'
,
function
()
{
if
(
notNull
(
formInputs
[
tplCtx
.
form
])
){
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
.
splice
(
taskPos
,
1
);
}
else
{
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
.
splice
(
taskPos
,
1
);
}
$
(
item
).
parent
().
parent
().
remove
();
});
},
editTodoItem
:
function
(
e
,
item
)
{
e
.
preventDefault
();
tplCtx
.
editTaskpos
=
$
(
item
).
parent
().
parent
().
data
(
"
pos
"
);
$
(
"
.bootbox #new-todo-item
"
).
val
(
$
(
item
).
parent
().
parent
().
find
(
"
.liText
"
).
text
()
);
$
(
"
.bootbox #new-todo-item-date
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
when
"
)
);
$
(
"
.bootbox #new-todo-item-price
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
price
"
)
);
$
(
"
.bootbox #new-todo-item-who option
"
).
prop
(
"
selected
"
,
false
)
if
(
$
(
item
).
parent
().
parent
().
data
(
"
who
"
).
indexOf
(
"
,
"
)){
whosT
=
$
(
item
).
parent
().
parent
().
data
(
"
who
"
).
split
(
"
,
"
);
$
.
each
(
whosT
,
function
(
i
,
u
){
$
(
"
.bootbox #new-todo-item-who option[value='
"
+
u
+
"
']
"
).
prop
(
"
selected
"
,
true
)
})
}
else
$
(
"
.bootbox #new-todo-item-who
"
).
val
(
$
(
item
).
parent
().
parent
().
data
(
"
who
"
)
);
},
function
completeTodoItem
()
{
alert
(
"
strike
"
);
$
(
this
).
parent
().
toggleClass
(
"
strike
"
);
completeTodoItem
:
function
()
{
tplCtx
.
editTaskpos
=
$
(
this
).
parent
().
parent
().
data
(
"
pos
"
);
var
today
=
new
Date
();
var
now
=
today
.
getDate
()
+
'
/
'
+
(
today
.
getMonth
()
+
1
)
+
'
/
'
+
today
.
getFullYear
()
+
'
'
+
today
.
getHours
()
+
'
:
'
+
today
.
getMinutes
();
var
taskPos
=
""
+
$
(
this
).
parent
().
parent
().
data
(
"
pos
"
);
if
(
$
(
this
).
is
(
"
:checked
"
)
){
if
(
notNull
(
formInputs
[
tplCtx
.
form
])
){
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
done
=
1
;
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
doneDate
=
now
;
}
else
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
doneDate
=
now
;
}
else
{
if
(
notNull
(
formInputs
[
tplCtx
.
form
])
){
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
done
=
0
;
delete
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
doneDate
;
}
else
{
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
done
=
0
;
delete
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
].
doneDate
;
}
}
var
todoObj
=
(
notNull
(
formInputs
[
tplCtx
.
form
])
)
?
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
]
:
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
[
taskPos
];
listObj
.
buildTodo
(
todoObj
,
tplCtx
.
editTaskpos
);
listObj
.
btnInit
();
var
todoDone
=
0
;
var
todos
=
null
;
if
(
notNull
(
formInputs
[
tplCtx
.
form
])
)
todos
=
answerObj
.
answers
[
tplCtx
.
form
][
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
;
else
todos
=
answerObj
.
answers
[
tplCtx
.
budgetpath
][
tplCtx
.
pos
].
todo
;
$
.
each
(
todos
,
function
(
ix
,
todo
)
{
if
(
parseInt
(
todo
.
done
)
==
1
)
todoDone
++
;
})
$
(
"
#btnTodo
"
+
tplCtx
.
pos
).
html
(
todoDone
+
"
/
"
+
todos
.
length
);
$
(
"
#todoProgress
"
+
tplCtx
.
pos
).
css
(
"
width
"
,
Math
.
floor
(
todoDone
*
100
/
todos
.
length
));
$
(
"
#todoPerc
"
+
tplCtx
.
pos
).
html
(
Math
.
floor
(
todoDone
*
100
/
todos
.
length
)
+
"
%
"
);
//alert(taskPos+"done"+todoDone+"/"+todos.length);
},
btnInit
:
function
()
{
$
(
"
.bootbox #todo-list
"
).
on
(
'
click
'
,
'
.todo-item-delete
'
,
function
(
e
){
var
item
=
this
;
listObj
.
deleteTodoItem
(
e
,
item
)
})
$
(
"
.bootbox #todo-list
"
).
on
(
'
click
'
,
'
.todo-item-edit
'
,
function
(
e
){
var
item
=
this
;
listObj
.
editTodoItem
(
e
,
item
)
})
$
(
"
.bootbox .todo-item-done
"
).
off
().
on
(
'
click
'
,
listObj
.
completeTodoItem
);
// $(".bootbox .liTodo").on('click', function(e){
// var item = this;
// editTodoItem(e, item)
// })
}
}
...
...
Write
Preview
Supports
Markdown
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