fix blogger

This commit is contained in:
Xuan Sang LE 2018-02-21 19:05:45 +01:00
parent 879c977fb2
commit efaafeac3e
6 changed files with 36 additions and 15 deletions

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title></title> <title>AntOS webOS</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link id="ostheme" rel="stylesheet" href=""> <link id="ostheme" rel="stylesheet" href="">

View File

@ -2,7 +2,7 @@
<afx-vbox > <afx-vbox >
<div data-height="5"></div> <div data-height="5"></div>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
<afx-label data-width= "70" text = "Title*:"></afx-label> <afx-label data-width= "70" text = "Title:"></afx-label>
<input type = "text" name="title" input-class = "user-input"/> <input type = "text" name="title" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-hbox data-height = "30" > <afx-hbox data-height = "30" >
@ -19,7 +19,7 @@
<afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label> <afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label>
<input type = "text" name="end" input-class = "user-input"/> <input type = "text" name="end" input-class = "user-input"/>
</afx-hbox> </afx-hbox>
<afx-label data-height = "30" text = "Content*:" style = "margin-left:5px;"/> <afx-label data-height = "30" text = "Content:" style = "margin-left:5px;"/>
<div data-id="editor-container"> <div data-id="editor-container">
<textarea name="content" data-id = "contentarea" /> <textarea name="content" data-id = "contentarea" />
</div> </div>

View File

@ -17,7 +17,7 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
sel = (d.find "content1").get "selectedItem" sel = (d.find "content1").get "selectedItem"
return d.notify "Please select a parent category" unless sel return d.notify "Please select a parent category" unless sel
val = (d.find "content3").value val = (d.find "content3").value
return d.notify "Please enter category name" if val is "" return d.notify "Please enter category name" if val is "" and not d.data.selonly
return d.notify "Parent can not be the category itself" if d.data.cat and d.data.cat.id is sel.id return d.notify "Parent can not be the category itself" if d.data.cat and d.data.cat.id is sel.id
d.handler { p: sel, value: val } if d.handler d.handler { p: sel, value: val } if d.handler
d.quit() d.quit()
@ -75,7 +75,7 @@ class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
console.log inputs console.log inputs
data[v.name] = ($ v).val() for v in inputs data[v.name] = ($ v).val() for v in inputs
data.content = me.editor.value() data.content = me.editor.value()
return me.notify "Title must not be blank" if data.title is "" return me.notify "Title or content must not be blank" if data.title is "" and data.content is ""
#return me.notify "Content must not be blank" if data.content is "" #return me.notify "Content must not be blank" if data.content is ""
data.id = me.data.id if me.data and me.data.id data.id = me.data.id if me.data and me.data.id
me.handler data if me.handler me.handler data if me.handler

View File

@ -70,7 +70,6 @@ class Blogger extends this.OS.GUI.BaseApplication
(d) -> (d) ->
return unless d return unless d
me.deleteCVCat cat me.deleteCVCat cat
me.refreshCVCat()
, "Delete cagegory" , , "Delete cagegory" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{cat.name} ?" } { iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{cat.name} ?" }
@ -88,6 +87,21 @@ class Blogger extends this.OS.GUI.BaseApplication
, "New section entry for #{cat.name}", null , "New section entry for #{cat.name}", null
(@find "cv-sec-move").set "onbtclick", (e) ->
sec = (me.find "cv-sec-list").get "selected"
return me.notify "Please select a section to move" unless sec
me.openDialog "BloggerCategoryDialog", (d) ->
c =
id: sec.id,
cid: d.p.id
me.cvsecdb.save c, (r) ->
return me.error "Cannot move section" if r.error
me.CVSectionByCID(sec.cid)
(me.find "cv-sec-list").set "selected", -1
, "Move to", { tree: (me.cvlist.get "data"), selonly: true }
(@find "cv-sec-edit").set "onbtclick", (e) -> (@find "cv-sec-edit").set "onbtclick", (e) ->
sec = (me.find "cv-sec-list").get "selected" sec = (me.find "cv-sec-list").get "selected"
return me.notify "Please select a section to edit" unless sec return me.notify "Please select a section to edit" unless sec
@ -99,7 +113,6 @@ class Blogger extends this.OS.GUI.BaseApplication
d.publish = Number sec.publish d.publish = Number sec.publish
me.cvsecdb.save d, (r) -> me.cvsecdb.save d, (r) ->
return me.error "Cannot save section: #{r.error}" if r.error return me.error "Cannot save section: #{r.error}" if r.error
console.log d.cid
me.CVSectionByCID Number(sec.cid) me.CVSectionByCID Number(sec.cid)
, "Modify section entry", sec , "Modify section entry", sec
@ -189,7 +202,10 @@ class Blogger extends this.OS.GUI.BaseApplication
name: "Porfolio", name: "Porfolio",
id:0, id:0,
nodes: [] nodes: []
@cvcatdb.get null, (d) -> cnd =
order:
name: "ASC"
@cvcatdb.find cnd, (d) ->
if d.error if d.error
me.cvlist.set "data", data me.cvlist.set "data", data
return me.notify "Cannot fetch CV categories" return me.notify "Cannot fetch CV categories"
@ -214,15 +230,15 @@ class Blogger extends this.OS.GUI.BaseApplication
ids.push c.id ids.push c.id
func(v) for v in c.nodes if c.nodes func(v) for v in c.nodes if c.nodes
func(cat) func(cat)
console.log dis
return cond = ({ "=": { cid: v } } for v in ids)
#delete all child
@deleteCVCat v for v in cat.nodes if cat.nodes
# delete all content # delete all content
@cvsecdb.delete { "=": { cid: cat.id } }, (r) -> @cvsecdb.delete { "or": cond }, (r) ->
return me.error "Cannot delete all content of: #{cat.name} [#{r.error}]" if r.error return me.error "Cannot delete all content of: #{cat.name} [#{r.error}]" if r.error
me.cvcatdb.delete cat.id, (re) -> cond = ({ "=": { id: v } } for v in ids)
me.cvcatdb.delete { "or": cond }, (re) ->
return me.error "Cannot delete the category: #{cat.name} [#{re.error}]" if re.error return me.error "Cannot delete the category: #{cat.name} [#{re.error}]" if re.error
me.refreshCVCat()
CVSectionByCID: (cid) -> CVSectionByCID: (cid) ->
me = @ me = @
@ -244,7 +260,10 @@ class Blogger extends this.OS.GUI.BaseApplication
v.end = Number(v.end) v.end = Number(v.end)
v.detail = [] v.detail = []
v.detail.push { text: v.subtitle, class: "cv-subtitle" } if v.subtitle isnt "" v.detail.push { text: v.subtitle, class: "cv-subtitle" } if v.subtitle isnt ""
v.detail.push { text: "#{v.start} - #{v.end}", class: "cv-period" } if v.start isnt 0 and v.end isnt 0 if v.start isnt 0 and v.end isnt 0
v.detail.push { text: "#{v.start} - #{v.end}", class: "cv-period" }
else
v.detail.push { text: "", class: "cv-period" }
v.detail.push { text: v.location, class: "cv-loc" } if v.location isnt "" v.detail.push { text: v.location, class: "cv-loc" } if v.location isnt ""
#v.detail.push { text: v.end } if v.end isnt 0 #v.detail.push { text: v.end } if v.end isnt 0
v.closable = true v.closable = true

View File

@ -67,6 +67,7 @@ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .c
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-period, .cv-loc{ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-period, .cv-loc{
text-align: right; text-align: right;
clear: both;
} }
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-subtitle{ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-subtitle{
font-style: italic; font-style: italic;

View File

@ -49,6 +49,7 @@
<div data-id = "cv-sec-status"></div> <div data-id = "cv-sec-status"></div>
<afx-button data-id = "cv-sec-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button> <afx-button data-id = "cv-sec-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
<afx-button data-id = "cv-sec-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button> <afx-button data-id = "cv-sec-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
<afx-button data-id = "cv-sec-move" data-width = "25" text = "" iconclass = "fa fa-exchange"></afx-button>
</afx-hbox> </afx-hbox>
</afx-vbox> </afx-vbox>
</afx-hbox> </afx-hbox>