Skip to content

Commit

Permalink
Improved properties and relations managment interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 27, 2011
1 parent b88f8fb commit 1a4cbb7
Show file tree
Hide file tree
Showing 22 changed files with 247 additions and 81 deletions.
4 changes: 2 additions & 2 deletions app/controllers/columns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def index
roles = {}
secure(Column) do
@columns = Column.paginate(:all, :order => 'role_id ASC, name ASC', :per_page => 200, :page => params[:page]).sort! do |a, b|
role_a = (roles[a.role_id] ||= a.role).name
role_b = (roles[b.role_id] ||= b.role).name
role_a = (roles[a.role_id] ||= a.role).kpath
role_b = (roles[b.role_id] ||= b.role).kpath

if role_a == role_b
a.name <=> b.name
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/relations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ def index
@relations = Relation.paginate(:all, :order => 'source_kpath', :per_page => 20, :page => params[:page])
end

@classes = {}
@relations.each do |rel|
(@classes[rel.source_kpath] ||= []) << ['src', rel]
(@classes[rel.target_kpath] ||= []) << ['trg', rel]
end

@classes.each do |k, list|
list.sort! do |a,b|
a_s = a[0] == 'src' ? a[1].target_role : a[1].source_role
b_s = b[0] == 'src' ? b[1].target_role : b[1].source_role
a_s <=> b_s
end
end

@relation = Relation.new
respond_to do |format|
format.html # index.erb
Expand Down
3 changes: 2 additions & 1 deletion app/views/columns/_add.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<tr id='add_column' class='btn_add'>
<td class='add'><%= link_to_function _('btn_column_add'), "['add_column', 'add_column_form'].each(Element.toggle); $('column_name').focus();" %></td><td class='add_column'></td>
<td class='add'><%= link_to_function _('btn_column_add'), "['add_column', 'add_column_form'].each(Element.toggle); $('column_name').focus();" %></td>
<td class='add_column' colspan='2'></td>
</tr>
<tr id='add_column_form' style='display:none;'>
<%= render :partial=>'columns/form' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/columns/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
link_to_function _('btn_x'), "['add_column', 'add_column_form'].each(Element.toggle)"
end %>
</td>
<td class="add">
<td class="add" colspan='2'>
<div id='column_errors'><%= error_messages_for(:column, :object => @column) %></div>
<% if @column.new_record? %>
<%= form_remote_tag(:url => columns_path ) %>
Expand Down
12 changes: 6 additions & 6 deletions app/views/columns/_li.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<tr id='column<%= li[:id] %>'>
<td class="adm_icon"><%= (li.new_record? || !li.errors.empty?) ? _('column_error_img') : link_to_remote( _('column_img'),
<td class="adm_icon"><%= (li.new_record? || !li.errors.empty?) ? _('column_error_img') : link_to_remote(_("img_#{li.ptype}"),
:update =>"column#{li[:id]}",
:url => edit_column_path(li),
:method => :get) %></td>
<td class='ruby'>
<span class='spacer'><%= (li.role.kind_of?(VirtualClass) ? '+ ' : '<span>* </span>') %></span>
<span class='constant'><%= li.role.name %></span>
<span class='text'>p.<%= li.ptype %></span>
<span class='string'>'<%= li.name %>'<span><% if !li.index.blank? -%>, <span class='symbol'>:index</span> =&gt; <span class='symbol'>:<%= li.index_name %></span><% end -%>
<td class='name'>
<%= li.name %>
</td>
<td class='index'>
<%= li.index_name %>
</td>
</tr>
13 changes: 11 additions & 2 deletions app/views/columns/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<h2 class='title'><%= _('properties') %></h2>

<table id='column_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='7'><%= will_paginate @columns %></th></tr>
<%= render :partial=>'columns/li', :collection=>@columns %>
<tr><th class='nav' colspan='3'><%= will_paginate @columns %></th></tr>
<% role = nil; @columns.each do |col| -%>
<% if col.role != role; role = col.role -%>
<tr>
<th class='nav sub <%= role.class %>' colspan='3'>
<span class='kpath'><%= role.kpath %></span> <%= role.name %>
</th>
</tr>
<% end -%>
<%= render :partial=>'columns/li', :collection=>[col] %>
<% end -%>
<%= render :partial=>'columns/add' %>
</table>
3 changes: 2 additions & 1 deletion app/views/relations/_add.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<tr id='add_relation' class='btn_add'>
<td class='add'><%= link_to_function _('btn_relation_add'), "['add_relation', 'add_relation_form'].each(Element.toggle); $('relation_source_role').focus();" %></td><td colspan='7' class='add_relation'></td>
<td class='add'><%= link_to_function _('btn_relation_add'), "['add_relation', 'add_relation_form'].each(Element.toggle); $('relation_source_role').focus();" %></td>
<td colspan='3' class='add_relation'></td>
</tr>
<tr id='add_relation_form' style='display:none;'>
<%= render :partial=>'relations/form' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/relations/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
link_to_function _('btn_x'), "['add_relation', 'add_relation_form'].each(Element.toggle)"
end %>
</td>
<td class="add" colspan="8">
<td class="add" colspan="3">
<div id='relation_errors'><%= error_messages_for(:relation, :object => @relation) %></div>
<% unless @relation.new_record? %>
<%= form_remote_tag(:url => relation_path(@relation), :method => :put ) %>
Expand Down
24 changes: 19 additions & 5 deletions app/views/relations/_li.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
<tr id='relation<%= li[:id] %><%= show_dir %>'>
<td class="dark"><%= link_to_remote(_('edit'),
<td class='adm_icon'><%= link_to_remote(_('img_relation'),
:update =>"relation#{li[:id]}#{show_dir}",
:url => edit_relation_path(li, :dir => show_dir),
:method => :get) %></td>
<td class="ruby relation" colspan='7'>
<% if show_dir == 'src' -%>
<span class='constant min_width'>
<%= VirtualClass.find_by_kpath(li.source_kpath) %></span> <span class='arity'><%= li.target_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.target_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.target_kpath).to_s %></span>
<td class='adm_icon'>
<%= li.target_unique? ? _('img_has_one') : _('img_has_many') %>
</td>
<td class='name'>
<%= li.target_role %>
</td>
<td class='other'>
<%= VirtualClass.find_by_kpath(li.target_kpath).to_s %>
</td>
<% else -%>
<span class='constant min_width'><%= VirtualClass.find_by_kpath(li.target_kpath) %></span> <span class='arity'><%= li.source_unique? ? _('has_one') : _('has_many') %></span> <span class='string'>'<%= li.source_role %>'</span>, <span class='symbol'>:class</span> => <span class='constant'><%= VirtualClass.find_by_kpath(li.source_kpath).to_s %></span><br/>
<td class='adm_icon'>
<%= li.source_unique? ? _('img_has_one') : _('img_has_many') %>
</td>
<td class='name'>
<%= li.source_role %>
</td>
<td class='other'>
<%= VirtualClass.find_by_kpath(li.source_kpath).to_s %>
</td>
<% end -%>
</td>
</tr>
15 changes: 11 additions & 4 deletions app/views/relations/index.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<h2 class='title'><%= _('relations') %></h2>
<table id='relation_list' class='admin' cellspacing="0">
<tr><th class='nav' colspan='9'><%= will_paginate @relations %></th></tr>
<%= @show_dir = 'src';render :partial=>'relations/li', :collection=>@relations %>
<tr><th class='nav' colspan='9'><%= _('reverse relation') %></th></tr>
<%= @show_dir = 'trg';render :partial=>'relations/li', :collection=>@relations.sort{|a,b| a.target_kpath <=> b.target_kpath} %>
<tr><th class='nav' colspan='4'><%= will_paginate @relations %></th></tr>
<% @classes.keys.sort.each do |kpath| -%>
<tr>
<th class='nav sub VirtualClass' colspan='4'>
<span class='kpath'><%= kpath %></span> <%= VirtualClass.find_by_kpath(kpath).to_s %>
</th>
</tr>
<% @classes[kpath].each do |dir, rel| -%>
<%= @show_dir = dir; render :partial=>'relations/li', :collection=>[rel] %>
<% end -%>
<% end -%>
<%= render :partial=>'relations/add' %>
</table>
6 changes: 6 additions & 0 deletions lib/gettext_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,11 @@ def CustomGettext
N_('clear_cache done.')
N_('rebuild_index')
N_('rebuild_index done.')

# Column types
N_('img_string')
N_('img_integer')
N_('img_float')
N_('img_datetime')
end
end
Binary file modified locale/de/LC_MESSAGES/zena.mo
Binary file not shown.
56 changes: 46 additions & 10 deletions locale/de/zena.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: version 0.0.1\n"
"POT-Creation-Date: 2011-05-26 21:27-0000\n"
"POT-Creation-Date: 2011-05-27 11:59-0000\n"
"PO-Revision-Date: 2010-06-02 16:45+0100\n"
"Last-Translator: Gaspard Bucher <gaspard@teti.ch>\n"
"Language-Team: de <lars@greiz-reinsdorf.de>\n"
Expand Down Expand Up @@ -318,12 +318,12 @@ msgstr "Vorgeschlagen zur Veröffentlichung"
msgid "Redaction published."
msgstr "zur Begutachtung gespeichert"

#: app/controllers/relations_controller.rb:52
#: app/controllers/relations_controller.rb:53
#, fuzzy
msgid "Relation was successfully created."
msgstr "Kommentar erfolgreich angelegt"

#: app/controllers/relations_controller.rb:69
#: app/controllers/relations_controller.rb:70
#, fuzzy
msgid "Relation was successfully updated."
msgstr "Information erfolgreich aktualisiert"
Expand Down Expand Up @@ -691,10 +691,6 @@ msgstr "<img src='/images/lock.png' title='closed'/>"
msgid "column_error_img"
msgstr "<img src='/images/brick_error.png' title='class error'/>"

#: app/views/columns/_li.html.erb:2
msgid "column_img"
msgstr ""

#: app/views/links/_form.rhtml:30
msgid "comment"
msgstr "Kommentar"
Expand Down Expand Up @@ -853,7 +849,7 @@ msgstr "Dokument"
msgid "drive_tab"
msgstr "drive"

#: app/views/relations/_li.erb:2 lib/zena/use/urls.rb:759
#: lib/zena/use/urls.rb:759
msgid "edit"
msgstr "bearbeiten"

Expand Down Expand Up @@ -935,12 +931,10 @@ msgid "has already been taken in %s"
msgstr ""

#: app/views/relations/_form.erb:23 app/views/relations/_form.erb:25
#: app/views/relations/_li.erb:7 app/views/relations/_li.erb:8
msgid "has_many"
msgstr ""

#: app/views/relations/_form.erb:22 app/views/relations/_form.erb:24
#: app/views/relations/_li.erb:7 app/views/relations/_li.erb:8
#, fuzzy
msgid "has_one"
msgstr "übernehmen"
Expand Down Expand Up @@ -1018,6 +1012,16 @@ msgstr ""
msgid "img_custom_inherit"
msgstr "<img src='/images/cog.png' title='custom rights'/>"

#: lib/gettext_strings.rb:186
#, fuzzy
msgid "img_datetime"
msgstr "%Y-%m-%d %H:%M"

#: lib/gettext_strings.rb:185
#, fuzzy
msgid "img_float"
msgstr "Bildformate"

#: lib/gettext_strings.rb:55
msgid "img_group"
msgstr "<img src='/images/group.png' title='group'/>"
Expand All @@ -1030,6 +1034,23 @@ msgstr "<img src='/images/group_pub.png' title='public group'/>"
msgid "img_group_site"
msgstr "<img src='/images/group_site.png' title='site group'/>"

#: app/views/relations/_li.erb:8 app/views/relations/_li.erb:10
#, fuzzy
msgid "img_has_many"
msgstr "<img src='/images/user_admin.png' title='administrator'/>"

#: app/views/relations/_li.erb:8 app/views/relations/_li.erb:10
#, fuzzy
msgid "img_has_one"
msgstr "übernehmen"

#: lib/gettext_strings.rb:184
#, fuzzy
msgid "img_integer"
msgstr ""
"<img src='/images/control_fastforward.png' title='next page' title='next "
"page'/>"

#: app/views/links/_li.rhtml:2
msgid "img_link"
msgstr "<img src='/images/tag_blue.png' title='Link'/>"
Expand Down Expand Up @@ -1058,6 +1079,16 @@ msgstr "<img src='/images/lock.png' title='Privat'/>"
msgid "img_public"
msgstr "<img src='/images/user_pub.png' title='public'/>"

#: app/views/relations/_li.erb:2
#, fuzzy
msgid "img_relation"
msgstr "Bezüge"

#: lib/gettext_strings.rb:183
#, fuzzy
msgid "img_string"
msgstr "<img src='/images/tag_blue.png' title='Link'/>"

#: lib/gettext_strings.rb:51
msgid "img_user"
msgstr "<img src='/images/user.png' title='user'/>"
Expand Down Expand Up @@ -1437,6 +1468,11 @@ msgstr "zurücksetzen"
msgid "retype new password"
msgstr "Passwort wiederholen"

#: app/views/relations/index.erb:16
#, fuzzy
msgid "reverse relation"
msgstr "<img src='/images/target.png' title='role'/>"

#: app/views/virtual_classes/index.erb:21
#, fuzzy
msgid "revert"
Expand Down
Binary file modified locale/en/LC_MESSAGES/zena.mo
Binary file not shown.
Binary file modified locale/en/zena.mo
Binary file not shown.

0 comments on commit 1a4cbb7

Please sign in to comment.