修訂 | 59 (tree) |
---|---|
時間 | 2008-03-14 01:04:26 |
作者 | junkikuchi |
updated.
@@ -297,13 +297,13 @@ | ||
297 | 297 | |
298 | 298 | { |
299 | 299 | :name => 'session.user.content.view.html.admin.bd.user', |
300 | - :class => 'Widget::User', | |
300 | + :class => 'Widget::UserAdmin', | |
301 | 301 | :row => {}, |
302 | 302 | :relation => {'view' => 'view:resource.admin.user'}, |
303 | 303 | }, |
304 | 304 | { |
305 | 305 | :name => 'session.user.content.view.html.admin.bd.user.list', |
306 | - :class => 'Widget::User::List', | |
306 | + :class => 'Widget::UserAdmin::List', | |
307 | 307 | :row => {}, |
308 | 308 | :relation => {'view' => 'view:resource.admin.user'}, |
309 | 309 | :preference => {} |
@@ -88,8 +88,10 @@ | ||
88 | 88 | end |
89 | 89 | |
90 | 90 | rs.inject({}) do |ret, (wid, val)| |
91 | - w = @model['widget'].fetch(wid) | |
92 | - ret[w] = val unless w.nil? | |
91 | + if w = @model['widget'].fetch(wid) | |
92 | + w.service = self | |
93 | + ret[w] = val | |
94 | + end | |
93 | 95 | ret |
94 | 96 | end.sort do |(aw, aval), (bw, bval)| |
95 | 97 | aw.min <=> bw.min |
@@ -102,6 +104,7 @@ | ||
102 | 104 | |
103 | 105 | ws.each do |wid, query| |
104 | 106 | if w = @model['widget'].fetch(wid) |
107 | + w.service = self | |
105 | 108 | w.__send__(method, self, query) |
106 | 109 | end |
107 | 110 | end |
@@ -0,0 +1,40 @@ | ||
1 | +# | |
2 | +# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com> | |
3 | +# | |
4 | + | |
5 | +Tenarai::ClassLoader.load_class('Widget::UserAdmin') | |
6 | + | |
7 | +class Widget | |
8 | + class UserAdmin | |
9 | + class List < ::Widget | |
10 | + extend Tenarai::ClassLoader | |
11 | + | |
12 | + preference_css 'box' | |
13 | + preference_css 'head', 'thead th' | |
14 | + preference_css 'body', 'tbody td' | |
15 | + | |
16 | + def render_html(xml, builder, content=nil) | |
17 | + xml.tag('div', 'id' => html_id) do |div| | |
18 | + div.tag('table') do |table| | |
19 | + table.tag('thead') do |th| | |
20 | + th.tag('tr') do |th| | |
21 | + th.tag('th').text('id') | |
22 | + th.tag('th').text('name') | |
23 | + th.tag('th').text('active') | |
24 | + end | |
25 | + end | |
26 | + table.tag('tbody') do |tb| | |
27 | + resource.each do |user| | |
28 | + tb.tag('tr') do |th| | |
29 | + th.tag('td').text(user.id) | |
30 | + th.tag('td').text(user.name) | |
31 | + th.tag('td').text(user.active) | |
32 | + end | |
33 | + end | |
34 | + end | |
35 | + end | |
36 | + end | |
37 | + end | |
38 | + end | |
39 | + end | |
40 | +end |
@@ -0,0 +1,22 @@ | ||
1 | +# | |
2 | +# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com> | |
3 | +# | |
4 | + | |
5 | +Tenarai::ClassLoader.load_class('Resource') | |
6 | + | |
7 | +class Widget | |
8 | + class UserAdmin < Resource | |
9 | + extend Tenarai::ClassLoader | |
10 | + | |
11 | + def new(row) | |
12 | + u = ::User.new(@service.model['user']) | |
13 | + u.name = row['name'] | |
14 | + u.password = row['password'] | |
15 | + u.save | |
16 | + end | |
17 | + | |
18 | + def each(&block) | |
19 | + @service.model['user'].each(&block) | |
20 | + end | |
21 | + end | |
22 | +end |
@@ -15,8 +15,9 @@ | ||
15 | 15 | |
16 | 16 | unless resource.content.view.include?(@content) |
17 | 17 | @content = resource.content.view |
18 | - @content.widget.load(@service) | |
19 | 18 | end unless resource.content.nil? |
19 | + | |
20 | + @content.widget.load(@service) | |
20 | 21 | end |
21 | 22 | end |
22 | 23 | end |
@@ -84,7 +84,11 @@ | ||
84 | 84 | 'visibility', |
85 | 85 | 'z_index', |
86 | 86 | 'display', |
87 | - ] | |
87 | + ], | |
88 | + | |
89 | + 'ui' => [ | |
90 | + 'cursor' | |
91 | + ], | |
88 | 92 | } |
89 | 93 | |
90 | 94 | class << self |
@@ -141,8 +145,17 @@ | ||
141 | 145 | self.class.fetch_resource(self) |
142 | 146 | end |
143 | 147 | |
148 | + def _build_url(param, _resource, _query) | |
149 | + if parent.nil? | |
150 | + @service | |
151 | + else | |
152 | + parent | |
153 | + end._build_url([], _resource, _query) | |
154 | + end | |
155 | + | |
144 | 156 | def url(*param, &block) |
145 | - resource.url(*param, &block) | |
157 | + #resource.url(*param, &block) | |
158 | + parent.url(*param, &block) | |
146 | 159 | end |
147 | 160 | |
148 | 161 | def init(*param) |
@@ -34,11 +34,7 @@ | ||
34 | 34 | _query[html_id] = _param |
35 | 35 | end |
36 | 36 | |
37 | - if resource.nil? | |
38 | - @service | |
39 | - else | |
40 | - resource | |
41 | - end._build_url([], _resource, _query) | |
37 | + super | |
42 | 38 | end |
43 | 39 | |
44 | 40 | def url(*param, &block) |