Class: DrbForm

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped, Eprint
Defined in:
lib/DrbDB/DrbForm.rb

Constant Summary

Constants included from Eprint

Eprint::TERM_COLOUR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Eprint

#ecode, #edebug, #eerror, #eeval, #eexception, #efatal, #einfo, #eprint, #ewarn, #getBinding, #report_mail

Constructor Details

#initialize(drbdb, my_id) ⇒ DrbForm

Returns a new instance of DrbForm.



9
10
11
12
13
# File 'lib/DrbDB/DrbForm.rb', line 9

def initialize(drbdb,my_id)
	@my_id=my_id.to_i
	@drbdb=drbdb
	@title="not loaded"
end

Instance Attribute Details

#moditemObject (readonly)

Returns the value of attribute moditem.



14
15
16
# File 'lib/DrbDB/DrbForm.rb', line 14

def moditem
  @moditem
end

#tabsObject (readonly)

Returns the value of attribute tabs.



14
15
16
# File 'lib/DrbDB/DrbForm.rb', line 14

def tabs
  @tabs
end

Instance Method Details

#cacheObject



60
61
62
# File 'lib/DrbDB/DrbForm.rb', line 60

def cache
	@drbdb.cache
end

#create_skeletonObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/DrbDB/DrbForm.rb', line 16

def create_skeleton
	@moditem=@drbdb.admin.qrow("select * from moditems where id='#{@my_id}'")
	@title=@moditem["display"]
	if @table=gtk_attribute("table")
		@querySQL="select * from `#{@table}` where id='\#{@parentselected}'"
		edebug("table(from attribute): #{@table.inspect}") unless @drbdb.main_server.starting_up
	else
		@querySQL=@moditem["querysql"]
		@table=@drbdb.admin.guess_base(@querySQL)
		edebug("table(guessed): #{@table.inspect}") unless @drbdb.main_server.starting_up
	end
	
	@batch=false
	@tabs=Hash.new
	items=Array.new
	@drbdb.admin.rows("select gtkformitems.*,modules.modname from gtkformitems left join moditems on gtkformitems.to_call = moditems.id left join modules on modules.id=moditems.modid where formid='#{@my_id}' order by y,x").each{|itemp|
		#Form suppots batch if at least one item supports it
		@batch=true if (@drbdb.gtk_attribute_of_object("batch",itemp["id"],"form-item") || "false").upcase == "TRUE"
		itemp["tab"]=@drbdb.gtk_attribute_of_object("tab",itemp["id"],"form-item") || "default"
		#add the missing tab item requires
		unless tabs.has_key?(itemp["tab"])
			tabs[itemp["tab"]]=Hash.new
			tabs[itemp["tab"]]["title"]=(itemp["tab"] == "default" ? "" : itemp["tab"])
		end
		tabs[itemp["tab"]]["minX"]=itemp["x"].to_i if !tabs[itemp["tab"]].has_key?("minX") || tabs[itemp["tab"]]["minX"]>itemp["x"].to_i
		tabs[itemp["tab"]]["minY"]=itemp["y"].to_i if !tabs[itemp["tab"]].has_key?("minY") || tabs[itemp["tab"]]["minY"]>itemp["y"].to_i
		tabs[itemp["tab"]]["maxX"]=itemp["x"].to_i if !tabs[itemp["tab"]].has_key?("maxX") || tabs[itemp["tab"]]["maxX"]<itemp["x"].to_i
		tabs[itemp["tab"]]["maxY"]=itemp["y"].to_i if !tabs[itemp["tab"]].has_key?("maxY") || tabs[itemp["tab"]]["maxY"]<itemp["y"].to_i
		items.push(itemp)
	}

	cache.set("#{@my_id}moditem",@moditem)
	cache.set("#{@my_id}attributes",{
		:querySQL=>@querySQL,
		:title=>@title,
		:table=>@table,
		:tabs=>tabs,
		:batch=>@batch
	})
	cache.set("#{@my_id}items",items)
	
	self
end

#get_idObject



65
66
67
# File 'lib/DrbDB/DrbForm.rb', line 65

def get_id
	@my_id
end

#gtk_attribute(gattr) ⇒ Object



68
69
70
# File 'lib/DrbDB/DrbForm.rb', line 68

def gtk_attribute(gattr)
	@drbdb.gtk_attribute(gattr,self)
end

#mod_typeObject



71
72
73
# File 'lib/DrbDB/DrbForm.rb', line 71

def mod_type
	"form"
end

#to_sObject



74
75
76
# File 'lib/DrbDB/DrbForm.rb', line 74

def to_s
	"DrbForm{#{@drbdb.name}:#{@title}(#{@my_id})}"
end