* change for create todo in block.

This commit is contained in:
wangyidong
2018-02-07 13:49:48 +08:00
parent e3f60c4af3
commit 1f4b2df38f
2 changed files with 36 additions and 2 deletions
+27 -1
View File
@@ -14,7 +14,7 @@
<div class='panel-body'>
<div class="todoes-input">
<div class="todo-form-trigger"><input type="text" placeholder="<?php echo $lang->todo->lblClickCreate?>" class="form-control"></div>
<form class="form-horizontal todoes-form layer" method='post' target='hiddenwin' action='<?php echo $this->createLink('todo', 'create');?>'>
<form class="form-horizontal todoes-form layer" method='post' target='hiddenwin' action='<?php echo $this->createLink('todo', 'create', 'date=today&account=&from=block');?>'>
<h3><?php echo $lang->todo->create . $lang->todo->common;?></h3>
<div class="form-group">
<div class="col-sm-12"><input required type="text" placeholder="<?php echo $lang->todo->name?>" class="form-control" name="name"></div>
@@ -94,5 +94,31 @@
});
});
});
function ajaxCreateTodo(obj)
{
var $todoes = $(obj).closest('.block-todoes');
var $form = $(obj).closest('form');
$.ajax(
{
type: "POST",
dataType: "json",
url: $form.attr('action'),
data: $form.serialize(),
success: function(todo)
{
var item = "<li data-id='" + todo.id + "'>";
item += '<span class="todo-check icon icon-check-circle"></span>';
item += '<a href="' + createLink('todo', 'view', "todoID=" + todo.id + "&from=my", 'html', true) + '" class="iframe">';
item += '<span class="todo-title">' + todo.name + '</span>';
item += '<span class="todo-pri todo-pri-' + todo.pri + '">' + todo.priName + '</span><span class="todo-time">' + todo.time + '</span></a></li>';
$todoes.find('ul.todoes').prepend(item);
$todoes.removeClass('show-form');
$todoes.find('ul.todoes li:first a').modalTrigger();
$form.find('input[name="name"]').val('');
$form.find('#todoDate').val('');
}
});
}
</script>
</div>
+9 -1
View File
@@ -34,7 +34,7 @@ class todo extends control
* @access public
* @return void
*/
public function create($date = 'today', $account = '')
public function create($date = 'today', $account = '', $from = 'todo')
{
if($date == 'today') $date = date::today();
if($account == '') $account = $this->app->user->account;
@@ -54,6 +54,14 @@ class todo extends control
}
if(!empty($_POST['idvalue'])) $this->send(array('result' => 'success'));
if($from == 'block')
{
$todo = $this->todo->getById($todoID);
$this->app->loadClass('date');
$todo->begin = date::formatTime($todo->begin);
$this->send(array('result' => 'success', 'id' => $todoID, 'name' => $todo->name, 'pri' => $todo->pri, 'priName' => $this->lang->todo->priList[$todo->pri], 'time' => date(DT_DATE4, strtotime($todo->date)) . ' ' . $todo->begin));
}
die(js::locate($this->createLink('my', 'todo', "type=$date"), 'parent'));
}