add shared library support

This commit is contained in:
Xuan Sang LE
2018-02-16 18:38:14 +01:00
parent dad5993c20
commit 13c6a1e9ff
23 changed files with 309 additions and 61 deletions

View File

@ -4,7 +4,7 @@ jsfiles =
cssfiles = main.css
copyfiles = scheme.html package.json
copyfiles = scheme.html cvsection.html package.json
PKG_NAME=Blogger

View File

@ -0,0 +1,28 @@
<afx-app-window data-id = "blogger-cv-sec-win" apptitle="Porforlio section" width="450" height="400">
<afx-vbox >
<afx-hbox data-height = "30" >
<afx-label data-width= "70" text = "Title*:"></afx-label>
<input type = "text" name="title" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "Subtitle:" data-width= "70"></afx-label>
<input type = "text" name="subtitle" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "Location:" data-width= "70"></afx-label>
<input type = "text" name="location" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "From:" data-width= "70"></afx-label>
<input type = "text" name="start" input-class = "user-input"/>
<afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label>
<input type = "text" name="end" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Content*:" style = "margin-left:5px;"/>
<textarea name="content" input-class = "user-input" style = "margin-left:5px; margin-right:5px;" />
<afx-hbox data-height = "30">
<div></div>
<afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="55" text = "Save"/>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -44,4 +44,30 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
}
this.OS.register "BloggerCategoryDialog", BloggerCategoryDialog
this.OS.register "BloggerCategoryDialog", BloggerCategoryDialog
# This dialog is use for cv section editing
class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
constructor: () ->
super "BloggerCVSectionDiaglog"
init: () ->
@render "#{@path()}/cvsection.html"
main: () ->
me = @
@scheme.set "apptitle", @title
inputs = me.select "[input-class='user-input']"
(($ v).val me.data[v.name] for v in inputs ) if me.data
(@find "bt-cv-sec-save").set "onbtclick", (e) ->
data = {}
console.log inputs
data[v.name] = ($ v).val() for v in inputs
return me.notify "Title must not be blank" if data.title 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
me.handler data if me.handler
me.quit()
this.OS.register "BloggerCVSectionDiaglog", BloggerCVSectionDiaglog

View File

@ -13,10 +13,11 @@ class Blogger extends this.OS.GUI.BaseApplication
@user = {}
@cvlist = @find "cv-list"
@cvlist.set "ontreeselect", (d) ->
#console.log d
me.CVSectionByCID Number(d.id)
@bloglist = @find "blog-list"
@userdb = new @_api.DB("user")
@cvcatdb = new @_api.DB("cv_cat")
@cvsecdb = new @_api.DB("cv_sections")
@tabbar.set "onlistselect", (e) ->
($ el).hide() for el in me.containers
me.fetchData e.idx
@ -56,7 +57,7 @@ class Blogger extends this.OS.GUI.BaseApplication
name: d.value
me.cvcatdb.save c, (r) ->
me.error "Cannot Edit category" if r.error
return me.error "Cannot Edit category" if r.error
me.refreshCVCat()
, "Edit category", { tree: (me.cvlist.get "data"), cat: cat }
@ -69,6 +70,35 @@ class Blogger extends this.OS.GUI.BaseApplication
console.log "delete all child + theirs content"
, "Delete cagegory" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{cat.name} ?" }
(@find "cv-sec-add").set "onbtclick", (e) ->
cat = me.cvlist.get "selectedItem"
return me.notify "Please select a category" unless cat and cat.id isnt 0
me.openDialog "BloggerCVSectionDiaglog", (d) ->
d.cid = Number cat.id
d.start = Number d.start
d.end = Number d.end
me.cvsecdb.save d, (r) ->
return me.error "Cannot save section: #{r.error}" if r.error
me.CVSectionByCID Number(cat.id)
, "New section entry for #{cat.name}", null
(@find "cv-sec-edit").set "onbtclick", (e) ->
sec = (me.find "cv-sec-list").get "selected"
return me.notify "Please select a section to edit" unless sec
me.openDialog "BloggerCVSectionDiaglog", (d) ->
d.cid = Number sec.cid
d.start = Number d.start
d.end = Number d.end
me.cvsecdb.save d, (r) ->
return me.error "Cannot save section: #{r.error}" if r.error
console.log d.cid
me.CVSectionByCID Number(sec.cid)
, "Modify section entry", sec
# USER TAB
fetchData: (idx) ->
me = @
switch idx
@ -77,13 +107,25 @@ class Blogger extends this.OS.GUI.BaseApplication
@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']"
inputs = me.select "[input-class='user-input']"
($ v).val me.user[v.name] for v in inputs
when 1 # category
@refreshCVCat()
else
console.log "Not implemented yet"
saveUser:() ->
me = @
inputs = @select "[input-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 ""
#console.log @user
@userdb.save @user, (r) ->
return me.error "Cannot save user data" if r.error
return me.notify "User data updated"
# PORFOLIO TAB
refreshCVCat: () ->
me = @
data =
@ -91,11 +133,13 @@ class Blogger extends this.OS.GUI.BaseApplication
id:0,
nodes: []
@cvcatdb.get null, (d) ->
return me.notify "Cannot fetch CV categories" if d.error
if d.error
me.cvlist.set "data", data
return me.notify "Cannot fetch CV categories"
me.fetchCVCat d.result, data, "0"
me.cvlist.set "data", data
it = (me.cvlist.find "pid", "2")[0]
me.cvlist.set "selectedItem", it
#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)
@ -105,17 +149,39 @@ class Blogger extends this.OS.GUI.BaseApplication
@fetchCVCat table, v, v.id
#v.nodes = null if v.nodes.length is 0
data.nodes.push v
saveUser:() ->
CVSectionByCID: (cid) ->
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 ""
#console.log @user
@userdb.save @user, (r) ->
return me.error "Cannot save user data" if r.error
return me.notify "User data updated"
@cvsecdb.find "cid=#{cid} ORDER BY start DESC", (d) ->
return me.notify "Section list is empty, please add one" if d.error
v.text = v.title for v in d.result
items = []
$(me.find "cv-sec-status").html "Found #{d.result.length} sections"
for v in d.result
v.text = v.title
v.complex = true
v.start = Number(v.start)
v.end = Number(v.end)
v.detail = []
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
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.closable = true
v.detail.push { text: v.content, class: "cv-content" }
items.push v
el = me.find "cv-sec-list"
el.set "onitemclose", (e) ->
d = me.openDialog "YesNoDialog", (b) ->
return unless b
me.cvsecdb.delete e.item.item.id, (r) ->
return me.error "Cannot delete the section: #{r.error}" if r.error
el.remove e.item.item, true
, "Delete section" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{e.item.item.text} ?" }
return false
el.set "items", items
Blogger.singleton = true
Blogger.dependencies = [ "mde/simplemde.min" ]
this.OS.register "Blogger", Blogger

View File

@ -40,3 +40,35 @@ afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-labe
text-align: center;
}
afx-app-window[data-id="blogger-cv-sec-win"] afx-hbox{
padding:5px;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li{
padding-bottom: 10px;
padding-top:10px;
/*border-bottom: 1px solid #cbcbcb;*/
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul afx-label{
font-weight: bold;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li.selected {
border: 2px solid #cbcbcb;
color: #414339;
background-color: transparent;
border-radius: 5px;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-content{
text-align: justify;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-period, .cv-loc{
text-align: right;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-subtitle{
font-style: italic;
float:left;
}
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] i.closable::before{
content: "\f014";
font-size: 15px;
}

View File

@ -6,26 +6,26 @@
<afx-vbox>
<afx-hbox data-height = "30">
<afx-label data-width= "70" text = "Full name:"></afx-label>
<input type = "text" name="fullname" imput-class = "user-input"/>
<input type = "text" name="fullname" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Address:" data-width= "70"></afx-label>
<input type = "text" name="address" imput-class = "user-input"/>
<input type = "text" name="address" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Phone:" data-width= "70"></afx-label>
<input type = "text" name="Phone" imput-class = "user-input"/>
<input type = "text" name="Phone" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Email:" data-width= "70"></afx-label>
<input type = "text" name="email" imput-class = "user-input"/>
<input type = "text" name="email" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Url:" data-width= "70"></afx-label>
<input type = "text" name="url" imput-class = "user-input"/>
<input type = "text" name="url" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Short biblio:"/>
<textarea name="shortbiblio" imput-class = "user-input"/>
<textarea name="shortbiblio" input-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"/>
@ -44,7 +44,12 @@
</afx-vbox>
<afx-resizer data-width = "3"/>
<afx-vbox>
info here
<afx-list-view data-id = "cv-sec-list" ></afx-list-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn">
<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-edit" data-width = "25" text = "" iconclass = "fa fa-pencil-square-o"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-hbox>
<afx-hbox data-id = "blog-container" data-height="100%">

View File

@ -58,7 +58,7 @@ class DummyApp extends this.OS.GUI.BaseApplication
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing", complex:true, content:[{text:"Inner content", class:""}]},
{text:"some thing", complex:true, detail:[{text:"Inner content", class:""}]},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},

View File

@ -1,8 +1,8 @@
coffee_files = main.coffee
jsfiles = simplemde.min.js
jsfiles =
cssfiles = simplemde.min.css main.css
cssfiles = main.css
copyfiles = scheme.html package.json

View File

@ -118,4 +118,6 @@ class MarkOn extends this.OS.GUI.BaseApplication
me.quit()
, "Quit", { text: "Quit without saving ?" }
MarkOn.dependencies = [ "mde/simplemde.min" ]
this.OS.register "MarkOn", MarkOn

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -279,4 +279,10 @@ class NotePad extends this.OS.GUI.BaseApplication
, "Quit", { text: "Ignore all #{dirties.length} unsaved files ?" }
NotePad.singleton = false
NotePad.dependencies = [
"ace/ace",
"ace/ext-language_tools",
"ace/ext-modelist",
"ace/ext-themelist"
]
this.OS.register "NotePad", NotePad