hypersonic-plus 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hdatastructures/hfieldtable.rb +285 -0
- data/lib/hdatastructures/hhash.rb +9 -0
- data/lib/hdatastructures/hlist.rb +100 -0
- data/lib/hdatastructures/hrecord.rb +75 -0
- data/lib/hdatastructures/hspreadfieldtable.rb +129 -0
- data/lib/hdb/hdataloader.rb +75 -0
- data/lib/hdb/hdb.rb +357 -0
- data/lib/hdb/hdb_test.rb +248 -0
- data/lib/hdb/hdbgenerator.rb +211 -0
- data/lib/hdb/hdbi.rb +63 -0
- data/lib/hdb/hdbi_test.rb +133 -0
- data/lib/hdb/hfield.rb +180 -0
- data/lib/hdb/hmysql.rb +99 -0
- data/lib/hdb/hmysql2.rb +96 -0
- data/lib/hdb/hodb.rb +948 -0
- data/lib/hdb/hpgsql.rb +54 -0
- data/lib/hengine/application_controller.rb +204 -0
- data/lib/hengine/hconfiguration.rb +40 -0
- data/lib/hengine/hhotlogger.rb +13 -0
- data/lib/hengine/hlogger.rb +119 -0
- data/lib/hengine/hmalloc.rb +275 -0
- data/lib/hengine/hmoduleloader.rb +15 -0
- data/lib/hengine/hsessiondata.rb +79 -0
- data/lib/hengine/hshareddata.rb +60 -0
- data/lib/hengine/htranslate.rb +40 -0
- data/lib/hengine/hviewloader.rb +99 -0
- data/lib/hinit/hinit.rb +3 -0
- data/lib/hmisc/hcolorize.rb +100 -0
- data/lib/hmisc/hdecoratorfunctions.rb +15 -0
- data/lib/hmisc/hdir.rb +19 -0
- data/lib/hmisc/hhtmlnode.rb +27 -0
- data/lib/hmisc/hinputvalidator.rb +95 -0
- data/lib/hmisc/hio.rb +142 -0
- data/lib/hmisc/hjson.rb +16 -0
- data/lib/hsqlmanager/hpgsqldatabasemanager.rb +76 -0
- data/lib/hsqlmanager/hsqldatabasemanager.rb +349 -0
- data/lib/hsqlmanager/hsqltable.rb +16 -0
- data/lib/husermanager/husermanager.rb +122 -0
- data/lib/hwidgets/haccordionmenu.rb +117 -0
- data/lib/hwidgets/hcheckboxtag.rb +33 -0
- data/lib/hwidgets/hdbactionbuttons.rb +26 -0
- data/lib/hwidgets/hdbcombobox.rb +71 -0
- data/lib/hwidgets/hdbdialogview.rb +190 -0
- data/lib/hwidgets/hdbfilterview.rb +28 -0
- data/lib/hwidgets/hdbtableview.rb +213 -0
- data/lib/hwidgets/hdbview.rb +63 -0
- data/lib/hwidgets/hdivtag.rb +9 -0
- data/lib/hwidgets/hdropdown.rb +44 -0
- data/lib/hwidgets/hformfield.rb +91 -0
- data/lib/hwidgets/hgrouptag.rb +65 -0
- data/lib/hwidgets/hhiddeninputtag.rb +12 -0
- data/lib/hwidgets/hinputtag.rb +55 -0
- data/lib/hwidgets/hlabeltag.rb +30 -0
- data/lib/hwidgets/hmainview.rb +37 -0
- data/lib/hwidgets/hpagination.rb +65 -0
- data/lib/hwidgets/hradiobuttontag.rb +30 -0
- data/lib/hwidgets/hselecttag.rb +32 -0
- data/lib/hwidgets/htableview.rb +262 -0
- data/lib/hwidgets/htabview.rb +84 -0
- data/lib/hwidgets/htextareatag.rb +20 -0
- data/lib/hwidgets/htopnav.rb +85 -0
- data/lib/hwidgets/hwidget.rb +423 -0
- data/lib/hypersonic.rb +9 -0
- metadata +276 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "hdatastructures/hspreadfieldtable"
|
3
|
+
|
4
|
+
class HSqlTable < HSpreadFieldTable
|
5
|
+
|
6
|
+
attr_accessor :tableName, :sortField, :filter
|
7
|
+
|
8
|
+
def initialize(tableName = nil, filter = "true", sortField = "id")
|
9
|
+
super()
|
10
|
+
@tableName = tableName
|
11
|
+
@filter = filter
|
12
|
+
@sortField = sortField
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
class HUserManager
|
2
|
+
|
3
|
+
include Singleton
|
4
|
+
include BCrypt
|
5
|
+
|
6
|
+
def initialize(databaseManager = nil)
|
7
|
+
|
8
|
+
@databaseManager = (databaseManager == nil) ? hpgsql() : databaseManager
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def sanitize(str)
|
13
|
+
|
14
|
+
return str.gsub("'", "\'")
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def userNameToUserId(userName)
|
19
|
+
|
20
|
+
query = "select id from user_table where username = '#{userName}'"
|
21
|
+
return @databaseManager.run(query).dataByFieldName(0, "id")
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def getUserValueById(userId, fieldName)
|
26
|
+
|
27
|
+
return nil if(fieldName == "")
|
28
|
+
fieldName = self.sanitize(fieldName)
|
29
|
+
|
30
|
+
query = "select profile_value from user_profile_table where profile_key = '#{fieldName}' and user_id = '#{userId}'";
|
31
|
+
return @databaseManager.run(query).dataByFieldName(0, "profile_value")
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def getUserValueByUserName(userName, fieldName)
|
37
|
+
|
38
|
+
return nil if(userName == "" || fieldName == "")
|
39
|
+
|
40
|
+
fieldName = self.sanitize(fieldName)
|
41
|
+
userId = userNameToUserId(userName)
|
42
|
+
|
43
|
+
return (userId == nil) ? nil : getUserValueById(userId, fieldName)
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def addProfileIfNotExist(userId, fieldName, fieldValue, ordering)
|
49
|
+
|
50
|
+
query = "select id from user_profile_table where profile_key = '#{fieldName}' and id = #{userId}"
|
51
|
+
resultTable = @databaseManager.run(query).resultTable
|
52
|
+
self.newUserProfile(userId, fieldName, fieldValue, ordering) if(resultTable.count == 0)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def newUserProfile(userId, profileKey, profileValue, ordering)
|
57
|
+
|
58
|
+
userProfile = Hash.new()
|
59
|
+
userProfile["user_id"] = userId
|
60
|
+
userProfile["profile_key"] = profileKey
|
61
|
+
userProfile["profile_value"] = profileValue
|
62
|
+
userProfile["ordering"] = ordering
|
63
|
+
userProfileQuery = "insert into user_profile_table #{@databaseManager.insertValues(userProfile)}"
|
64
|
+
@databaseManager.run(userProfileQuery)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def newUser(user)
|
69
|
+
|
70
|
+
user[:password] = Password.create(HIO.unQuote(user[:password]))
|
71
|
+
user[:activation] = Digest::SHA1.hexdigest([Time.now, rand].join)
|
72
|
+
userQuery = "insert into user_table #{@databaseManager.insertValues(user)} returning id"
|
73
|
+
return @databaseManager.run(userQuery).dataByFieldName(0, "id")
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# return nil if user not found
|
78
|
+
# return -1 if mismatch password
|
79
|
+
# return id if the username and password are ok
|
80
|
+
|
81
|
+
def autenticate(username, password)
|
82
|
+
|
83
|
+
query = "select id, password from user_table where username = '#{username}'"
|
84
|
+
resultTable = @databaseManager.run(query).resultTable
|
85
|
+
return nil if(resultTable.count == 0)
|
86
|
+
storePassword = resultTable[0]["password"]
|
87
|
+
return Password.new(storePassword).is_password?(password) ? resultTable[0]["id"] : -1
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def deleteUser(username)
|
92
|
+
|
93
|
+
query = "delete from user_table where username = '#{username}'"
|
94
|
+
@databaseManager.run(query)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def activationUrl(username)
|
100
|
+
|
101
|
+
query = "select activation from user_table where username = '#{username}'"
|
102
|
+
return @databaseManager.run(query).dataByFieldName(0, "activation")
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def self.test1()
|
108
|
+
|
109
|
+
userProfile = {:name => "Herbert", :familienname => "Bonaffini", :adresse => "Wien", :arbeit => "Developer"}
|
110
|
+
p hpgsql().insertValues(userProfile)
|
111
|
+
p hpgsql().updateValues(userProfile)
|
112
|
+
|
113
|
+
HUserManager.instance().addProfileIfNotExist(1, "familienname", "Bonaffini", 1)
|
114
|
+
user = {:id => 'default', :username => "herbert.bonaffini9@gmail.com", :password => "ciao", :enabled => 1, :user_type_id => 1}
|
115
|
+
#p "id: #{HUserManager.instance().newUser(user)}"
|
116
|
+
p "autenticate: #{HUserManager.instance().autenticate('herbert.bonaffini9@gmail.com', "ciao")}"
|
117
|
+
p HUserManager.instance().activationUrl("herbert.bonaffini9@gmail.com")
|
118
|
+
return HUserManager.instance().getUserValueByUserName('herbert.bonaffini@gmail.com', 'address')
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
class HAccordionMenu < HDivTag
|
2
|
+
|
3
|
+
attr_reader :mainView
|
4
|
+
|
5
|
+
def initialize(items: [], id: nil, mainView: nil)
|
6
|
+
super(class: "haccordion-menu")
|
7
|
+
self.set(id: id) if id
|
8
|
+
#self.appendChild(HWidget.new("style", "##{id}:target { display: block; }", scoped: nil));
|
9
|
+
@items = items
|
10
|
+
@mainView = mainView
|
11
|
+
end
|
12
|
+
|
13
|
+
def addItem(value)
|
14
|
+
@items << value
|
15
|
+
return self
|
16
|
+
end
|
17
|
+
|
18
|
+
def a(innerHTML = '', icon: nil, **args)
|
19
|
+
|
20
|
+
a = HWidget.new("a", "", args)
|
21
|
+
a << HWidget.new('span', class: icon) if icon
|
22
|
+
a << HWidget.new('span', innerHTML)
|
23
|
+
return a
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def onClick(moduleName: nil, modelName: nil)
|
28
|
+
hl << "HAccordionMenu.onClick (#{moduleName} - #{modelName})".red
|
29
|
+
return @mainView.html(moduleName: moduleName, modelName: modelName)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def appendChildren(parent, items)
|
34
|
+
|
35
|
+
items.each do |value|
|
36
|
+
if(value[:type] == 'link')
|
37
|
+
ref = eval(value[:ref]) if value[:ref]
|
38
|
+
parent << link = (self.a(value[:name], icon: value[:icon]))
|
39
|
+
link.connect(:onclick, self, "onClick", id: @mainView.oid, args: ref)
|
40
|
+
elsif(value[:type].include? 'section' )
|
41
|
+
parent.appendChild( HDivTag.new(value[:name], class: "#{value[:type]}-name") )
|
42
|
+
sectionContentDiv = HDivTag.new(class: "#{value[:type]}-content")
|
43
|
+
parent.appendChild(sectionContentDiv)
|
44
|
+
self.appendChildren(sectionContentDiv, value[:content])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def html()
|
52
|
+
self.appendChildren(self, @items)
|
53
|
+
return super
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.test1()
|
57
|
+
|
58
|
+
subSection = [
|
59
|
+
{type: 'section', name: 'Section-A', content:[
|
60
|
+
{type: 'link', name: 'Section-a1', href:'#'},
|
61
|
+
{type: 'link', name: 'Section-a2', href:'#'},
|
62
|
+
{type: 'link', name: 'Section-a3', href:'#'}
|
63
|
+
]
|
64
|
+
},
|
65
|
+
|
66
|
+
{type: 'section', name: 'Section-B', content:[
|
67
|
+
{type: 'link', name: 'Section-b1', href:'#'},
|
68
|
+
{type: 'link', name: 'Section-b2', href:'#'},
|
69
|
+
{type: 'link', name: 'Section-b3', href:'#'}
|
70
|
+
]
|
71
|
+
},
|
72
|
+
]
|
73
|
+
|
74
|
+
openSection = [{type: 'link', name: 'O-Section1', href:'#', icon: 'glyphicon glyphicon-user'},
|
75
|
+
{type: 'link', name: 'O-Section2', href:'#'},
|
76
|
+
{type: 'link', name: 'O-Section3', href:'#'}
|
77
|
+
]
|
78
|
+
|
79
|
+
items = [
|
80
|
+
{type: 'section', name: 'Section-A', content:[
|
81
|
+
{type: 'link', name: 'Section-a1', href:'#'},
|
82
|
+
{type: 'link', name: 'Section-a2', href:'#'},
|
83
|
+
{type: 'link', name: 'Section-a3', href:'#'}
|
84
|
+
]
|
85
|
+
},
|
86
|
+
|
87
|
+
{type: 'section', name: 'Section-B', content: subSection},
|
88
|
+
{type: 'open-section', name: 'Open Section', content: openSection},
|
89
|
+
]
|
90
|
+
return HAccordionMenu.new(items).html()
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.appendChild1(parent, root = [])
|
95
|
+
parent.children.each do |item|
|
96
|
+
next if item.name == "text"
|
97
|
+
menuItem = item.to_h.symbolize_keys
|
98
|
+
if item.name == "menusection"
|
99
|
+
menuItem[:type] = "section" unless menuItem[:type]
|
100
|
+
menuItem[:content] = self.appendChild1(item)
|
101
|
+
elsif item.name == "menuitem"
|
102
|
+
menuItem[:type] = "link"
|
103
|
+
end
|
104
|
+
root << menuItem
|
105
|
+
end
|
106
|
+
return root
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.loadMenuByModuleName(moduleName: nil, mainView: nil)
|
111
|
+
menuView = hv().viewByFileName(moduleName, "app/modules/#{moduleName}/menu_view.xml")
|
112
|
+
items = self.appendChild1(menuView.hypersonic)
|
113
|
+
return HAccordionMenu.new(items: items, id: moduleName, mainView: mainView).html()
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "hwidgets/hgrouptag"
|
4
|
+
|
5
|
+
class HCheckBoxTag < HGroupTag
|
6
|
+
|
7
|
+
attr_accessor :checked
|
8
|
+
|
9
|
+
def initialize(name = nil, modelName = nil, placeholder = nil)
|
10
|
+
super(name, modelName, placeholder)
|
11
|
+
@checkBox = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def html()
|
15
|
+
for i in (0..@items.count - 1) do
|
16
|
+
item = @items[i]
|
17
|
+
value = @values[i]
|
18
|
+
id = "#{@modelName}_#{@name}_#{value.downcase()}"
|
19
|
+
name = "#{@modelName}[#{@name}][#{value}]"
|
20
|
+
hiddenCheckBox = HInputTag.new(@name, @modelName, nil, nil, type = "hidden").set(name: name, value: "0")
|
21
|
+
checkBox = HInputTag.new(@name, @modelName, value, nil, type = "checkbox") if (@checkBox == nil)
|
22
|
+
checkBox.placeholder = item
|
23
|
+
checkBox.set(checked: "") if (@selectedItem[value.to_s] == "1")
|
24
|
+
checkBox.set(name: name, value: "1", id: id)
|
25
|
+
checkBox.setReverse()
|
26
|
+
self << checkBox << hiddenCheckBox
|
27
|
+
end
|
28
|
+
|
29
|
+
return super()
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class HDBActionButtons < HDivTag
|
2
|
+
|
3
|
+
def initialize(sourceView: nil, buttons: [], **args)
|
4
|
+
|
5
|
+
@sourceView = sourceView
|
6
|
+
@buttons = buttons
|
7
|
+
|
8
|
+
return super(class: 'hdbactionbuttons', **args)
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def html
|
13
|
+
|
14
|
+
@buttons.each do |button|
|
15
|
+
action = button.delete(:action)
|
16
|
+
button = HWidget.new("button", button.delete(:name), class: "actionbutton", **button)
|
17
|
+
button.connect(:onclick, @sourceView, "rpcAction", args: {action: action},
|
18
|
+
id: @sourceView.oid, mode: 'none',
|
19
|
+
attributes: ":hdbTableView.ids(obj) => ids")
|
20
|
+
self << button
|
21
|
+
end
|
22
|
+
|
23
|
+
return super
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
require "hwidgets/hdivtag"
|
3
|
+
require "hwidgets/hgrouptag"
|
4
|
+
require "hwidgets/hinputtag"
|
5
|
+
|
6
|
+
class HDBComboBox < HDivTag
|
7
|
+
|
8
|
+
attr_accessor :selectTag, :newButton, :editButton
|
9
|
+
|
10
|
+
# fieldName: products_id
|
11
|
+
# showField: name
|
12
|
+
|
13
|
+
def initialize(moduleName, odb, fieldName, showedFieldName, label, selectedValue, oid, dialogLevel)
|
14
|
+
@odb = odb
|
15
|
+
@fieldName = fieldName
|
16
|
+
@showedFieldName = showedFieldName
|
17
|
+
@label = label
|
18
|
+
@selectedValue = selectedValue
|
19
|
+
@oid = oid
|
20
|
+
@dialogLevel = dialogLevel
|
21
|
+
|
22
|
+
@sourceModelName = odb.source.modelName
|
23
|
+
@moduleName = moduleName
|
24
|
+
@modelName = odb.modelName
|
25
|
+
super(id: oid)
|
26
|
+
|
27
|
+
@selectTag = HSelectTag.new("id", "#{@sourceModelName}[#{fieldName}]", label)
|
28
|
+
@selectTag.setCarriageReturn()
|
29
|
+
@selectTag.set(id: "#{@modelName}-combobox", overwrite: true)
|
30
|
+
|
31
|
+
self << @selectTag
|
32
|
+
self << @newButton = HInputTag.init(name: "new", type: "button")
|
33
|
+
@newButton.connect(:onclick, self, "newRecord", getElem: "body", mode: "add", id: @oid);
|
34
|
+
self << @editButton = HInputTag.init(name: "edit", type: "button")
|
35
|
+
@editButton.connect(:onclick, self, "edit", attributeById: "#{@modelName}-combobox", attributes: ":obj.value", getElem: "body", mode: "add", id: @oid);
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def html(selectedValue = @selectedValue)
|
40
|
+
|
41
|
+
puts "#############################################@:#{selectedValue}".red
|
42
|
+
fieldTable = @odb.toFieldTable
|
43
|
+
@selectTag.setItems(fieldTable.column(@showedFieldName, "key")).setValues(fieldTable.column("id", :key))
|
44
|
+
@selectTag.setSelected(selectedValue) if (selectedValue)
|
45
|
+
|
46
|
+
return super()
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def closeButton()
|
51
|
+
puts "closeButton".red
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def edit(recordId)
|
56
|
+
puts "recordId: #{recordId}".red
|
57
|
+
dialogView = HDBDialogView.new(recordId, @moduleName, @odb, @oid, @dialogLevel)
|
58
|
+
dialogView.closeButton.connect(:onclick, self, "closeButton", before: 'hdialogView.close()', mode: 'none', id: @oid)
|
59
|
+
dialogView.connect(:onsubmit, self, "html", submit: true, id: @oid, args:[recordId])
|
60
|
+
return dialogView.html(:edit)
|
61
|
+
end
|
62
|
+
|
63
|
+
def newRecord()
|
64
|
+
nvr = @odb.create # new virtual record
|
65
|
+
dialogView = HDBDialogView.new(nvr.id, @moduleName, @odb, @oid, @dialogLevel)
|
66
|
+
dialogView.closeButton.connect(:onclick, self, "closeButton", before: 'hdialogView.close()', mode: 'none', id: @oid)
|
67
|
+
dialogView.connect(:onsubmit, self, "html", submit: true, id: @oid, args:["#{nvr.id}#"])
|
68
|
+
return dialogView.html(:new)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
class HDBDialogView < HWidget
|
2
|
+
|
3
|
+
attr_accessor :closeButton, :cancelButton, :odb, :modelName, :oid, :dialogLevel
|
4
|
+
|
5
|
+
def initialize(id, moduleName, odb, poid, dialogLevel)
|
6
|
+
super("form", method: "POST")
|
7
|
+
@moduleName = moduleName
|
8
|
+
@modelName = odb.modelName.to_s
|
9
|
+
@oid = hm().malloc(self, poid).obj.object_id.to_s
|
10
|
+
@dialogLevel = dialogLevel + 1
|
11
|
+
@id = id
|
12
|
+
@formFields = self.formFields()
|
13
|
+
@fieldTable = HSpreadFieldTable.new()
|
14
|
+
@fieldTable.addFieldName(0)
|
15
|
+
@fieldTable.addFieldName(1)
|
16
|
+
@tableView = HTableView.new(fieldTable: @fieldTable)
|
17
|
+
@tableView.set(align: "center")
|
18
|
+
@tabs = {}
|
19
|
+
@tabView = HTabView.new(@tabs, @modelName)
|
20
|
+
@odb = odb
|
21
|
+
|
22
|
+
@dialogHeader = self.dialogHeader()
|
23
|
+
@dialogFooter = self.dialogFooter()
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.initByTableView(id, dbTableView)
|
28
|
+
return HDBDialogView.new(id, dbTableView.moduleName, dbTableView.odb, dbTableView.oid, dbTableView.dialogLevel)
|
29
|
+
end
|
30
|
+
|
31
|
+
def formFields
|
32
|
+
|
33
|
+
keywords = {
|
34
|
+
name: 'name',
|
35
|
+
label: 'label',
|
36
|
+
'panel.name': 'panel',
|
37
|
+
type: 'type',
|
38
|
+
visible: 'visible',
|
39
|
+
default: 'default',
|
40
|
+
hidden: 'hidden',
|
41
|
+
lineedit: 'lineedit',
|
42
|
+
combobox: 'combobox',
|
43
|
+
dbcombobox: 'dbcombobox',
|
44
|
+
radiobutton: 'radiobutton',
|
45
|
+
checkbox: 'checkbox',
|
46
|
+
textarea: 'textarea',
|
47
|
+
dbtable: 'dbtable',
|
48
|
+
submit: 'submit',
|
49
|
+
show_field: 'show_field',
|
50
|
+
items: 'items',
|
51
|
+
values: 'values',
|
52
|
+
js_function: 'js_function',
|
53
|
+
properties: 'properties',
|
54
|
+
validator: 'validator'
|
55
|
+
}
|
56
|
+
|
57
|
+
formFields = []
|
58
|
+
hv().viewParsing(@moduleName, @modelName, :form).each do |node|
|
59
|
+
record = HRecord.new(node.name)
|
60
|
+
keywords.each do |key, value|
|
61
|
+
key = key.to_s
|
62
|
+
nodeValue = node.value(key)
|
63
|
+
record.set(value, nodeValue) if nodeValue
|
64
|
+
end
|
65
|
+
formFields << record
|
66
|
+
end
|
67
|
+
return formFields
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def setWidget(row, col, widget, tabName = nil)
|
73
|
+
|
74
|
+
unless(tabName)
|
75
|
+
@fieldTable.setData(row, col, HRecord.new(widget))
|
76
|
+
return
|
77
|
+
end
|
78
|
+
|
79
|
+
tabName = tabName.downcase.delete(' ')
|
80
|
+
unless(@tabs.key?(tabName))
|
81
|
+
fieldTable = HSpreadFieldTable.new()
|
82
|
+
fieldTable.addFieldName(0)
|
83
|
+
fieldTable.addFieldName(1)
|
84
|
+
tableView = HTableView.new(fieldTable: fieldTable)
|
85
|
+
@tabs[tabName] = {tabCaption: tabName, tabContain: tableView}
|
86
|
+
end
|
87
|
+
|
88
|
+
@tabs[tabName][:tabContain].fieldTable.setData(row, col, HRecord.new(widget))
|
89
|
+
end
|
90
|
+
|
91
|
+
def addJsf(formField, jsfList)
|
92
|
+
|
93
|
+
if(jsfList)
|
94
|
+
jsfList.each do |jsf|
|
95
|
+
formField.addJsFunction(jsf[0], jsf[1], *jsf.drop(2))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
def systemRecords()
|
102
|
+
|
103
|
+
hiddenFormFields = HDivTag.new(class: "system-records")
|
104
|
+
hiddenFormFields << HHiddenInputTag.new("@modelName", @modelName)
|
105
|
+
hiddenFormFields << HHiddenInputTag.new("@objectId", @odb.object_id)
|
106
|
+
hiddenFormFields << HHiddenInputTag.new("@dialogLevel", @dialogLevel)
|
107
|
+
return hiddenFormFields
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
def setFieldValidator(w, odb)
|
112
|
+
|
113
|
+
map = Hash.new('length')
|
114
|
+
map[:integer] = 'integer, length'
|
115
|
+
map[:float] = 'real, length'
|
116
|
+
map[:text] = 'length'
|
117
|
+
|
118
|
+
type = odb.fieldProperty(w.name, "type")
|
119
|
+
mandatory = odb.fieldProperty(w.name, "mandatory")
|
120
|
+
type = type.to_sym if type
|
121
|
+
fieldValidator = map[type]
|
122
|
+
fieldValidator += ", mandatory" if mandatory
|
123
|
+
fieldValidator.split(',').uniq.join(',')
|
124
|
+
w.validator = fieldValidator if w.value == 'field'
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
def dialogHeader
|
129
|
+
|
130
|
+
@closeButton = HWidget.new("button").set(type: "button", class: "close-btn").setInnerHTML("X")
|
131
|
+
|
132
|
+
divHeader = HDivTag.new(class: "header")
|
133
|
+
divHeader << @closeButton
|
134
|
+
|
135
|
+
return divHeader
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
def dialogFooter
|
140
|
+
|
141
|
+
@cancelButton = HWidget.new("button").set(type: "button", class: "cancel-btn").setInnerHTML("Cancel")
|
142
|
+
|
143
|
+
@okButton = HWidget.new("input").set(type: "submit", class: "ok-btn", value: "Ok")
|
144
|
+
|
145
|
+
divFooter = HDivTag.new(class: "footer")
|
146
|
+
divFooter << @okButton << @cancelButton
|
147
|
+
|
148
|
+
return divFooter
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
# cols e' il numero di colonne
|
154
|
+
def html(cols = 1)
|
155
|
+
puts "result: #{@id} - #{@modelName}"
|
156
|
+
set(method: "post", action: "submit/params")
|
157
|
+
i = 0
|
158
|
+
@odb = @odb.odb if @odb.class == HRecordPtr
|
159
|
+
@odb.findByOffLine({id: @id})
|
160
|
+
@formFields.each do |w| # w like widget
|
161
|
+
puts "name, type: #{w.name}, #{w.type}".red
|
162
|
+
w.type = w.type.downcase
|
163
|
+
w.visible = w.visible ? w.visible.to_b : true
|
164
|
+
next if(w.visible == false)
|
165
|
+
w.set(:value, @odb.data(w.name))
|
166
|
+
w.set("#id", @id)
|
167
|
+
w.set("#dialogLevel", @dialogLevel)
|
168
|
+
self.setFieldValidator(w, @odb)
|
169
|
+
formField = HFormField.new(@moduleName, w, @odb, @oid, @dialogLevel).obj()
|
170
|
+
formField.set(eval(w.properties)) if(w.properties)
|
171
|
+
formField.connect(:onblur, "HInputValidator", "valid?",
|
172
|
+
attributes: ':obj.value => fieldValue', # obj.value verra passato attraverso fieldValue
|
173
|
+
after: 'hdialogView.fieldValidator(obj, response)', getElem: 'none', mode: 'none',
|
174
|
+
args: {fieldType: w.validator, fieldName: w.name, modelName: @modelName},
|
175
|
+
id: @oid) if w.validator
|
176
|
+
#formField.addJsFunction(:onblur, "setValue") # non server piu in quanto uso ':obj.value'
|
177
|
+
|
178
|
+
w.panel += "-#{@dialogLevel}" if w.panel
|
179
|
+
self.setWidget(i / cols, i % cols, formField, w.panel)
|
180
|
+
i += 1
|
181
|
+
end
|
182
|
+
|
183
|
+
self << @dialogHeader << @tableView << @tabView << @dialogFooter << self.systemRecords()
|
184
|
+
|
185
|
+
divDialog = HDivTag.new(super(), class: "hdialog")
|
186
|
+
return divDialog.html()
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|