improve database reading in Blogger

This commit is contained in:
Xuan Sang LE 2018-03-07 10:57:01 +01:00
parent 88a78c7eef
commit 241b8caa6b

View File

@ -162,9 +162,11 @@ class Blogger extends this.OS.GUI.BaseApplication
@bloglist.set "onlistselect", (e) -> @bloglist.set "onlistselect", (e) ->
sel = me.bloglist.get "selected" sel = me.bloglist.get "selected"
return unless sel return unless sel
me.editor.value atob(sel.content) me.blogdb.get Number(sel.id), (r) ->
me.inputtags.value = sel.tags me.error "Cannot fetch the entry content" if r.error
(me.find "blog-publish").set "swon", (if Number(sel.publish) then true else false) me.editor.value atob(r.result.content)
me.inputtags.value = r.result.tags
(me.find "blog-publish").set "swon", (if Number(r.result.publish) then true else false)
@.bloglist.set "onitemclose", (e) -> @.bloglist.set "onitemclose", (e) ->
me.openDialog "YesNoDialog", (b) -> me.openDialog "YesNoDialog", (b) ->
@ -356,13 +358,19 @@ class Blogger extends this.OS.GUI.BaseApplication
cond = cond =
order: order:
ctime: "DESC" ctime: "DESC"
fields: [
"id",
"title",
"ctimestr",
"utimestr"
]
@blogdb.find cond, (r) -> @blogdb.find cond, (r) ->
return me.notify "No post found: #{r.error}" if r.error return me.notify "No post found: #{r.error}" if r.error
console.log r.result
for v in r.result for v in r.result
v.text = v.title v.text = v.title
v.complex = true v.complex = true
v.closable = true v.closable = true
v.content = v.content.unescape()
v.detail = [ v.detail = [
{ text: "Created: #{v.ctimestr}", class: "blog-dates" }, { text: "Created: #{v.ctimestr}", class: "blog-dates" },
{ text: "Updated: #{v.utimestr}", class: "blog-dates" }] { text: "Updated: #{v.utimestr}", class: "blog-dates" }]