mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 03:09:45 +02:00
fix tree view, add features to Blogger
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
coffee_files = main.coffee
|
||||
coffee_files = dialogs.coffee main.coffee
|
||||
|
||||
jsfiles =
|
||||
|
||||
|
47
src/packages/Blogger/dialogs.coffee
Normal file
47
src/packages/Blogger/dialogs.coffee
Normal file
@ -0,0 +1,47 @@
|
||||
class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
|
||||
constructor: () ->
|
||||
super "BloggerCategoryDialog", {
|
||||
tags: [
|
||||
{ tag: "afx-label", att: "data-height = '20', text = 'Pick a parent:'" },
|
||||
{ tag: "afx-tree-view" },
|
||||
{ tag: "afx-label", att: "data-height = '20', text = 'Category name:'" },
|
||||
{ tag: "input", att: "type = 'text' data-height = '20'" }
|
||||
],
|
||||
width: 200,
|
||||
height: 300,
|
||||
resizable: true,
|
||||
buttons: [
|
||||
{
|
||||
label: "0k",
|
||||
onclick: (d) ->
|
||||
sel = (d.find "content1").get "selectedItem"
|
||||
return d.notify "Please select a parent category" unless sel
|
||||
val = (d.find "content3").value
|
||||
return d.notify "Please enter category name" if val is ""
|
||||
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.quit()
|
||||
},
|
||||
{
|
||||
label: "Cancel",
|
||||
onclick: (d) -> d.quit()
|
||||
}
|
||||
],
|
||||
filldata: (d) ->
|
||||
return unless d.data
|
||||
#console.log d.data
|
||||
tree = d.find "content1"
|
||||
tree.set "data", d.data.tree if d.data.tree
|
||||
if d.data.cat
|
||||
it = (tree.find "id", d.data.cat.pid)[0]
|
||||
tree.set "selectedItem", it
|
||||
(d.find "content3").value = d.data.cat.name
|
||||
#(d.find "content0").set "text", d.data.label
|
||||
#(d.find "content1").value = d.data.value if d.data.value
|
||||
xtra: (d) ->
|
||||
$( d.find "content3" ).keyup (e) ->
|
||||
(d.find "bt0").trigger() if e.which is 13
|
||||
}
|
||||
|
||||
|
||||
this.OS.register "BloggerCategoryDialog", BloggerCategoryDialog
|
@ -12,11 +12,16 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
]
|
||||
@user = {}
|
||||
@cvlist = @find "cv-list"
|
||||
@cvlist.set "ontreeselect", (d) ->
|
||||
#console.log d
|
||||
@bloglist = @find "blog-list"
|
||||
@userdb = new @_api.DB("user")
|
||||
@cvcatdb = new @_api.DB("cv_cat")
|
||||
@tabbar.set "onlistselect", (e) ->
|
||||
($ el).hide() for el in me.containers
|
||||
me.fetchData e.idx
|
||||
($ me.containers[e.idx]).show()
|
||||
me.trigger "calibrate"
|
||||
|
||||
@tabbar.set "items", [
|
||||
{ iconclass: "fa fa-user-circle", selected: true },
|
||||
@ -25,29 +30,90 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
]
|
||||
(@find "bt-user-save").set "onbtclick", (e) ->
|
||||
me.saveUser()
|
||||
|
||||
|
||||
(@find "cv-cat-add").set "onbtclick", (e) ->
|
||||
me.openDialog "BloggerCategoryDialog",
|
||||
(d) ->
|
||||
c =
|
||||
name: d.value,
|
||||
pid: d.p.id,
|
||||
publish: 1
|
||||
me.cvcatdb.save c, (r) ->
|
||||
me.error "Cannot add new category" if r.error
|
||||
me.refreshCVCat()
|
||||
#update the list
|
||||
|
||||
, "Add category", { tree: me.cvlist.get "data" }
|
||||
|
||||
(@find "cv-cat-edit").set "onbtclick", (e) ->
|
||||
cat = me.cvlist.get "selectedItem"
|
||||
return unless cat
|
||||
me.openDialog "BloggerCategoryDialog", (d) ->
|
||||
c =
|
||||
id: cat.id,
|
||||
publish: cat.publish,
|
||||
pid: d.p.id,
|
||||
name: d.value
|
||||
|
||||
me.cvcatdb.save c, (r) ->
|
||||
me.error "Cannot Edit category" if r.error
|
||||
me.refreshCVCat()
|
||||
, "Edit category", { tree: (me.cvlist.get "data"), cat: cat }
|
||||
|
||||
(@find "cv-cat-del").set "onbtclick", (e) ->
|
||||
cat = me.cvlist.get "selectedItem"
|
||||
return unless cat
|
||||
me.openDialog "YesNoDialog",
|
||||
(d) ->
|
||||
return unless d
|
||||
console.log "delete all child + theirs content"
|
||||
, "Delete cagegory" ,
|
||||
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{cat.name} ?" }
|
||||
fetchData: (idx) ->
|
||||
me = @
|
||||
switch idx
|
||||
when 0 #user info
|
||||
db = new @_api.DB("user")
|
||||
db.get null, (d) ->
|
||||
|
||||
@userdb.get null, (d) ->
|
||||
return me.error "Cannot fetch user data" if d.error
|
||||
me.user = d.result[0]
|
||||
inputs = me.select "[imput-class='user-input']"
|
||||
($ v).val me.user[v.name] for v in inputs
|
||||
when 1 # category
|
||||
@refreshCVCat()
|
||||
else
|
||||
console.log "Not implemented yet"
|
||||
|
||||
refreshCVCat: () ->
|
||||
me = @
|
||||
data =
|
||||
name: "Porfolio",
|
||||
id:0,
|
||||
nodes: []
|
||||
@cvcatdb.get null, (d) ->
|
||||
return me.notify "Cannot fetch CV categories" if d.error
|
||||
me.fetchCVCat d.result, data, "0"
|
||||
me.cvlist.set "data", data
|
||||
it = (me.cvlist.find "pid", "2")[0]
|
||||
me.cvlist.set "selectedItem", it
|
||||
|
||||
fetchCVCat: (table, data, id) ->
|
||||
result = (v for v in table when v.pid is id)
|
||||
return data.nodes = null if result.length is 0
|
||||
for v in result
|
||||
v.nodes = []
|
||||
@fetchCVCat table, v, v.id
|
||||
#v.nodes = null if v.nodes.length is 0
|
||||
data.nodes.push v
|
||||
|
||||
|
||||
saveUser:() ->
|
||||
me = @
|
||||
inputs = @select "[imput-class='user-input']"
|
||||
@user[v.name] = ($ v).val() for v in inputs
|
||||
return @notify "Full name must be entered" if not @user.fullname or @user.fullname is ""
|
||||
db = new @_api.DB("user")
|
||||
console.log @user
|
||||
db.save @user, (r) ->
|
||||
#console.log @user
|
||||
@userdb.save @user, (r) ->
|
||||
return me.error "Cannot save user data" if r.error
|
||||
return me.notify "User data updated"
|
||||
|
||||
|
@ -4,13 +4,13 @@ afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] {
|
||||
background-color: #333333;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] li {
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] > div > ul > li {
|
||||
background-color: #333333;
|
||||
font-size: 20px;
|
||||
color: #929292;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] li.selected{
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] > div > ul > li.selected{
|
||||
color:white;
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] {
|
||||
@ -22,4 +22,21 @@ afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-hbo
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label{
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-hbox.cv-side-bar-btn{
|
||||
padding-left:3px;
|
||||
padding-top:3px;
|
||||
background-color: #f6F6F6;
|
||||
border-top: 1px solid #cbcbcb;
|
||||
color:#414339;
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-resizer{
|
||||
border-left: 1px solid #cbcbcb;
|
||||
background-color: transparent;
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-label.cat-header{
|
||||
background-color: #f6F6F6;
|
||||
border-bottom: 1px solid #cbcbcb;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<afx-app-window data-id = "blogger-win" apptitle="MarketPlace" width="500" height="400">
|
||||
<afx-app-window data-id = "blogger-win" apptitle="Blogger" width="500" height="500">
|
||||
<afx-hbox >
|
||||
<afx-list-view data-id="tabbar" data-width="30"></afx-list-view>
|
||||
<afx-vbox>
|
||||
<afx-hbox data-id="user-container" data-height="grow">
|
||||
<afx-hbox data-id="user-container" data-height="100%">
|
||||
<afx-vbox>
|
||||
<afx-hbox data-height = "30">
|
||||
<afx-label data-width= "70" text = "Full name:"></afx-label>
|
||||
@ -25,20 +25,29 @@
|
||||
<input type = "text" name="url" imput-class = "user-input"/>
|
||||
</afx-hbox>
|
||||
<afx-label data-height = "30" text = "Short biblio:"/>
|
||||
<textarea rows="10" name="shortbiblio" imput-class = "user-input"/>
|
||||
<afx-hbox data-height = "30">
|
||||
<textarea name="shortbiblio" imput-class = "user-input"/>
|
||||
<afx-hbox data-height = "35">
|
||||
<div></div>
|
||||
<afx-button iconclass = "fa fa-save" data-id = "bt-user-save" data-width="55" text = "Save"/>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox data-id="cv-container" data-height="grow">
|
||||
<afx-list-view data-id = "cv-list" data-width="100" ></afx-list-view>
|
||||
<afx-hbox data-id="cv-container" data-height="100%">
|
||||
<afx-vbox data-width="150" min-width="100">
|
||||
<afx-label class = "cat-header" data-height = "23" text = "Categories" iconclass = "fa fa-bars"></afx-label>
|
||||
<afx-tree-view data-id = "cv-list" ></afx-tree-view>
|
||||
<afx-hbox data-height="30" class = "cv-side-bar-btn">
|
||||
<afx-button data-id = "cv-cat-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
|
||||
<afx-button data-id = "cv-cat-del" data-width = "25" text = "" iconclass = "fa fa-minus-circle"></afx-button>
|
||||
<afx-button data-id = "cv-cat-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width = "3"/>
|
||||
<afx-vbox>
|
||||
info here
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox data-id = "blog-container" data-height="grow">
|
||||
<afx-hbox data-id = "blog-container" data-height="100%">
|
||||
<afx-list-view data-id = "blog-list" data-width="100"></afx-list-view>
|
||||
<afx-vbox>
|
||||
blog here
|
||||
|
@ -23,7 +23,7 @@ class DummyApp extends this.OS.GUI.BaseApplication
|
||||
tdata = {
|
||||
name: 'My Tree',
|
||||
nodes: [
|
||||
{ name: 'hello', icon:'fa fa-car'},
|
||||
{ name: 'hello', iconclass:'fa fa-car'},
|
||||
{ name: 'wat' },
|
||||
{
|
||||
name: 'child folder',
|
||||
@ -48,7 +48,7 @@ class DummyApp extends this.OS.GUI.BaseApplication
|
||||
}
|
||||
]
|
||||
}
|
||||
tree.set "*",tdata
|
||||
tree.set "data",tdata
|
||||
|
||||
list = @find "mylist"
|
||||
ldata = [
|
||||
@ -58,7 +58,7 @@ class DummyApp extends this.OS.GUI.BaseApplication
|
||||
{text:"some thing"},
|
||||
{text:"some thing"},
|
||||
{text:"some thing"},
|
||||
{text:"some thing"},
|
||||
{text:"some thing", complex:true, content:[{text:"Inner content", class:""}]},
|
||||
{text:"some thing"},
|
||||
{text:"some thing"},
|
||||
{text:"some thing"},
|
||||
|
@ -22,7 +22,7 @@ afx-app-window[data-id="notepad"] .afx-window-content {
|
||||
background-color: #f6F6F6;
|
||||
}
|
||||
|
||||
afx-tab-container[data-id="tabarea"] afx-list-view li {
|
||||
afx-tab-container[data-id="tabarea"] afx-list-view > div.list-container > ul > li {
|
||||
background-color: #dfdfdf;
|
||||
color:#272822;
|
||||
border: 0;
|
||||
@ -39,7 +39,7 @@ afx-tab-container[data-id="tabarea"] afx-list-view{
|
||||
/*afx-tab-container[data-id="tabarea"] afx-list-view i.closable:before{
|
||||
color: white;
|
||||
}*/
|
||||
afx-tab-container[data-id="tabarea"] afx-list-view li.selected {
|
||||
afx-tab-container[data-id="tabarea"] afx-list-view > div.list-container > ul > li.selected {
|
||||
background-color: #f6F6F6;
|
||||
border-radius: 0;
|
||||
}
|
Reference in New Issue
Block a user