Fixed edit entry post issue
This commit is contained in:
parent
6a4fd98a03
commit
766fe4425d
@ -83,7 +83,7 @@ class Api
|
|||||||
$put['status'] = true;
|
$put['status'] = true;
|
||||||
$put['data'] = $update;
|
$put['data'] = $update;
|
||||||
$put['count'] = count($put['data']);
|
$put['count'] = count($put['data']);
|
||||||
$put['message'] = ucfirst($table) . ' berhasil diubah';
|
$put['message'] = 'Proses berhasil';
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
@ -107,7 +107,7 @@ class Api
|
|||||||
$post['status'] = true;
|
$post['status'] = true;
|
||||||
$post['data'] = $entry;
|
$post['data'] = $entry;
|
||||||
$post['count'] = count($post['data']);
|
$post['count'] = count($post['data']);
|
||||||
$post['message'] = ucfirst($table) . ' berhasil ditambahkan';
|
$post['message'] = 'Proses berhasil';
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -192,7 +192,7 @@ class Home
|
|||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'route_to' => '',
|
'route_to' => '',
|
||||||
'message' => 'User berhasil ditambahkan'
|
'message' => 'Proses berhasil'
|
||||||
]);die();
|
]);die();
|
||||||
}
|
}
|
||||||
Session::flash('info', 'Registrasi berhasil');
|
Session::flash('info', 'Registrasi berhasil');
|
||||||
|
@ -338,7 +338,7 @@ class Posts
|
|||||||
}
|
}
|
||||||
$post['status'] = true;
|
$post['status'] = true;
|
||||||
$post['route_to'] = '';
|
$post['route_to'] = '';
|
||||||
$post['message'] = 'Pengumuman berhasil ditambahkan';
|
$post['message'] = 'Proses berhasil';
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($post);
|
echo json_encode($post);
|
||||||
die();
|
die();
|
||||||
@ -412,10 +412,14 @@ class Posts
|
|||||||
$length = strlen($args['content']);
|
$length = strlen($args['content']);
|
||||||
$args['delay'] = $length * 84;
|
$args['delay'] = $length * 84;
|
||||||
|
|
||||||
|
$d = new \DateTime();
|
||||||
|
$d = $d->format('Y-m-d H:i:s');
|
||||||
|
$args['edited_at'] = $d;
|
||||||
|
|
||||||
if ($this->model->update($args, $id)) {
|
if ($this->model->update($args, $id)) {
|
||||||
$update['status'] = true;
|
$update['status'] = true;
|
||||||
$update['route_to'] = '';
|
$update['route_to'] = '';
|
||||||
$update['message'] = 'Pengumuman berhasil diubah';
|
$update['message'] = 'Proses berhasil';
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($update);
|
echo json_encode($update);
|
||||||
die();
|
die();
|
||||||
|
@ -15,13 +15,13 @@ var createPost = {
|
|||||||
var valid_at = rome(left, {
|
var valid_at = rome(left, {
|
||||||
dateValidator: rome.val.beforeEq(right),
|
dateValidator: rome.val.beforeEq(right),
|
||||||
time: false,
|
time: false,
|
||||||
inputFormat: 'YYYY/MM/DD',
|
inputFormat: 'YYYY-MM-DD',
|
||||||
required: true
|
required: true
|
||||||
})
|
})
|
||||||
var expired_at = rome(right, {
|
var expired_at = rome(right, {
|
||||||
dateValidator: rome.val.afterEq(left),
|
dateValidator: rome.val.afterEq(left),
|
||||||
time: false,
|
time: false,
|
||||||
inputFormat: 'YYYY/MM/DD',
|
inputFormat: 'YYYY-MM-DD',
|
||||||
required: true
|
required: true
|
||||||
})
|
})
|
||||||
var simplemde = new SimpleMDE({ element: document.getElementById("smde") });
|
var simplemde = new SimpleMDE({ element: document.getElementById("smde") });
|
||||||
|
@ -7,20 +7,22 @@ let post = require('../models/post')
|
|||||||
|
|
||||||
var createPost = {
|
var createPost = {
|
||||||
oninit: function(vnode) {
|
oninit: function(vnode) {
|
||||||
|
post.current = {}
|
||||||
post.loadCurrent(vnode.attrs.id)
|
post.loadCurrent(vnode.attrs.id)
|
||||||
category.loadList(1)
|
category.loadList(1)
|
||||||
},
|
},
|
||||||
oncreate: function() {
|
oncreate: function() {
|
||||||
|
clearInterval(window.intv)
|
||||||
var valid_at = rome(left, {
|
var valid_at = rome(left, {
|
||||||
dateValidator: rome.val.beforeEq(right),
|
dateValidator: rome.val.beforeEq(right),
|
||||||
time: false,
|
time: false,
|
||||||
inputFormat: 'YYYY/MM/DD',
|
inputFormat: 'YYYY-MM-DD',
|
||||||
required: true
|
required: true
|
||||||
})
|
})
|
||||||
var expired_at = rome(right, {
|
var expired_at = rome(right, {
|
||||||
dateValidator: rome.val.afterEq(left),
|
dateValidator: rome.val.afterEq(left),
|
||||||
time: false,
|
time: false,
|
||||||
inputFormat: 'YYYY/MM/DD',
|
inputFormat: 'YYYY-MM-DD',
|
||||||
required: true
|
required: true
|
||||||
})
|
})
|
||||||
var simplemde = new SimpleMDE({ element: document.getElementById("smde") });
|
var simplemde = new SimpleMDE({ element: document.getElementById("smde") });
|
||||||
@ -35,7 +37,7 @@ var createPost = {
|
|||||||
},
|
},
|
||||||
view: function() {
|
view: function() {
|
||||||
return m('main.documentation', m('section', [
|
return m('main.documentation', m('section', [
|
||||||
m('h2', 'Tambah Pengumuman'),
|
m('h2', 'Ubah Pengumuman'),
|
||||||
m('form', {
|
m('form', {
|
||||||
onsubmit: function(e) {
|
onsubmit: function(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -73,10 +75,12 @@ var createPost = {
|
|||||||
onfocusout: m.withAttr('value', function(value) {
|
onfocusout: m.withAttr('value', function(value) {
|
||||||
post.current.valid_at = value
|
post.current.valid_at = value
|
||||||
}),
|
}),
|
||||||
value: fecha.format(
|
value: post.current.valid_at ?
|
||||||
post.current.valid_at ? new Date(post.current.valid_at)
|
fecha.format(
|
||||||
: new Date(),
|
fecha.parse(post.current.valid_at, 'YYYY-MM-DD HH:mm:ss'),
|
||||||
'YYYY/MM/DD')
|
'YYYY-MM-DD'
|
||||||
|
)
|
||||||
|
: ''
|
||||||
}),
|
}),
|
||||||
m('br'),
|
m('br'),
|
||||||
m('label', {for: 'expired_at'}, 'Berlaku sampai: '),
|
m('label', {for: 'expired_at'}, 'Berlaku sampai: '),
|
||||||
@ -85,10 +89,12 @@ var createPost = {
|
|||||||
onfocusout: m.withAttr('value', function(value) {
|
onfocusout: m.withAttr('value', function(value) {
|
||||||
post.current.expired_at = value
|
post.current.expired_at = value
|
||||||
}),
|
}),
|
||||||
value: fecha.format(
|
value: post.current.expired_at ?
|
||||||
post.current.expired_at ? new Date(post.current.expired_at)
|
fecha.format(
|
||||||
: new Date(),
|
fecha.parse(post.current.expired_at, 'YYYY-MM-DD HH:mm:ss'),
|
||||||
'YYYY/MM/DD')
|
'YYYY-MM-DD'
|
||||||
|
)
|
||||||
|
: ''
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
m('.full.two-third-600', [
|
m('.full.two-third-600', [
|
||||||
|
@ -22,19 +22,19 @@ var listAdmin = {
|
|||||||
'data-tooltip':
|
'data-tooltip':
|
||||||
pengumuman.categoryName
|
pengumuman.categoryName
|
||||||
+ "\nAktif: "
|
+ "\nAktif: "
|
||||||
+ fecha.format(fecha.parse(pengumuman.valid_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
+ fecha.format(fecha.parse(pengumuman.valid_at, 'YYYY-MM-DD HH:mm:ss'), 'YYYY-MM-DD')
|
||||||
+ ' - '
|
+ ' - '
|
||||||
+ fecha.format(fecha.parse(pengumuman.expired_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
+ fecha.format(fecha.parse(pengumuman.expired_at, 'YYYY-MM-DD HH:mm:ss'), 'YYYY-MM-DD')
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ 'Diubah: '
|
+ 'Diubah: '
|
||||||
+ fecha.format(fecha.parse(pengumuman.edited_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
+ fecha.format(fecha.parse(pengumuman.edited_at, 'YYYY-MM-DD HH:mm:ss'), 'YYYY-MM-DD')
|
||||||
}, [
|
}, [
|
||||||
m('em', {
|
m('em', {
|
||||||
style: 'color: ' + pengumuman.foreground
|
style: 'color: ' + pengumuman.foreground
|
||||||
}, [
|
}, [
|
||||||
pengumuman.creatorName,
|
pengumuman.creatorName,
|
||||||
' - ',
|
' - ',
|
||||||
fecha.format(fecha.parse(pengumuman.created_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
fecha.format(fecha.parse(pengumuman.created_at, 'YYYY-MM-DD HH:mm:ss'), 'YYYY-MM-DD')
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
m('span.stack', {style:'color:' + pengumuman.foreground + '; overflow-y: auto;'}, m.trust(marked(pengumuman.content))),
|
m('span.stack', {style:'color:' + pengumuman.foreground + '; overflow-y: auto;'}, m.trust(marked(pengumuman.content))),
|
||||||
|
@ -75,12 +75,12 @@ var post = {
|
|||||||
post.current = _.find(post.list, function(o) { return o.id == id })
|
post.current = _.find(post.list, function(o) { return o.id == id })
|
||||||
if (post.current.status == 2) {
|
if (post.current.status == 2) {
|
||||||
post.current.status = 1
|
post.current.status = 1
|
||||||
post.current.valid_at = fecha.format(new Date(), 'YYYY/MM/DD')
|
var d = new Date();
|
||||||
|
post.current.valid_at = fecha.format(new Date(), 'YYYY-MM-DD H:mm:s')
|
||||||
} else if (post.current.status == 1) {
|
} else if (post.current.status == 1) {
|
||||||
post.current.status = 0
|
post.current.status = 0
|
||||||
}
|
}
|
||||||
post.save()
|
post.save()
|
||||||
// console.log(post.current);
|
|
||||||
},
|
},
|
||||||
validateStatus: function(id) {
|
validateStatus: function(id) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user