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