Fixed edit entry post issue

This commit is contained in:
2017-10-27 14:34:55 +07:00
parent 6a4fd98a03
commit 766fe4425d
7 changed files with 34 additions and 24 deletions

View File

@@ -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") });

View File

@@ -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', [

View File

@@ -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))),

View File

@@ -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) {