From 1f695f7c84b971ba685c880e48906f6106f10e17 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 27 Apr 2014 01:34:38 +0100 Subject: [PATCH] Added groups styling --- app/assets/stylesheets/application.css.scss | 2 +- app/assets/stylesheets/pages/_groups.scss | 57 +++++++++ app/assets/stylesheets/pages/_news.scss | 28 +++++ app/models/group.rb | 2 +- app/views/articles/admin.html.erb | 36 +++--- app/views/groups/edit.html.erb | 133 +++++++++++--------- app/views/groups/index.html.erb | 28 ++--- app/views/groups/show.html.erb | 47 ++++--- config/locales/en.yml | 1 + 9 files changed, 212 insertions(+), 122 deletions(-) create mode 100644 app/assets/stylesheets/pages/_groups.scss diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 287616a..8189629 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -57,4 +57,4 @@ @import "pages/bans"; @import "pages/issues"; @import "pages/servers"; - +@import "pages/groups"; diff --git a/app/assets/stylesheets/pages/_groups.scss b/app/assets/stylesheets/pages/_groups.scss new file mode 100644 index 0000000..90333cd --- /dev/null +++ b/app/assets/stylesheets/pages/_groups.scss @@ -0,0 +1,57 @@ +/* + Groups List +*/ + +table.groups { + + .name { + width: 50%; + } + + .created { + width: 20%; + } + + .founder { + width: 20%; + } + + .actions { + width: 10%; + text-align: right; + } +} + +/* + Groups Page +*/ + +#group { + + table.roles { + + .name, + .username { + width: 20%; + } + + .role { + width: 60%; + } + + .fields { + margin: 0; + float: left; + } + + .controls { + margin: 0; + float: right; + + .remove { + margin-bottom: 0; + margin-right: 0; + } + } + } +} diff --git a/app/assets/stylesheets/pages/_news.scss b/app/assets/stylesheets/pages/_news.scss index 33d2547..06e0041 100644 --- a/app/assets/stylesheets/pages/_news.scss +++ b/app/assets/stylesheets/pages/_news.scss @@ -136,4 +136,32 @@ form.article { .button.new { margin-top: em(20); } +} + +/* + Admin Articles Page +*/ + +div.admin.articles { + + .title { + width: 40%; + } + + .category { + width: 20%; + } + + .created { + width: 20%; + } + + .author { + width: 10%; + } + + .actions { + width: 10%; + text-align: right; + } } \ No newline at end of file diff --git a/app/models/group.rb b/app/models/group.rb index 63487f3..df76445 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -43,7 +43,7 @@ class Group < ActiveRecord::Base end def can_destroy? cuser - cuser and cuser.admin? + cuser and cuser.admin? and id != Group::ADMINS end def self.staff diff --git a/app/views/articles/admin.html.erb b/app/views/articles/admin.html.erb index 1ed7e2e..4fe4893 100644 --- a/app/views/articles/admin.html.erb +++ b/app/views/articles/admin.html.erb @@ -1,34 +1,30 @@ -

- Draft Articles -

+
+

Articles Admin

-<% @articles.each do |key, articles| %> -
-

- <%= h key %> -

+ <% @articles.each do |key, articles| %> +

<%=h key %>

- +
- - - - - + + + + + <% for article in articles %> - + - <% end %>
TitleCategoryCreatedAuthorOptionsTitleCategoryCreatedAuthor
<%= namelink article %> <%= h article.category %> <%= shorttime article.created_at %> <%= namelink article.user %> - <%= link_to 'Edit', edit_article_path(article) %> - <%= link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete %> + + <%= link_to icon('pencil'), edit_article_path(article) %> + <%= link_to icon('times'), article, confirm: 'Are you sure?', method: :delete %>
-
-<% end %> + <% end %> +
diff --git a/app/views/groups/edit.html.erb b/app/views/groups/edit.html.erb index daa82f6..bb50f90 100644 --- a/app/views/groups/edit.html.erb +++ b/app/views/groups/edit.html.erb @@ -1,71 +1,82 @@ -

Editing group: <%= h @group.name %>

+
+

Editing Group: <%= h @group.name %>

-
- +
+ -
-
- <%= form_for(@group) do |f| %> - <%= f.error_messages %> -

- <%= f.label :name %>
- <%= f.text_field :name %> -

-

- <%= f.submit "Update" %> -

- <% end %> -
+
+
+ <%= form_for(@group, html: { class: 'square' }) do |f| %> + <%= render 'shared/errors', messages: @group.errors.full_messages %> -
- - - - - - - +
+ <%= f.label :name %> + <%= f.text_field :name %> +
+ +
+ <%= f.submit 'Update' %> +
+ <% end %> + - <% # TODO fixaa tämä - @group.groupers.each do |grouper| %> - - <%= form_for grouper do |g| %> +
+
UsernameReal NameTaskOptions
+ + + + + + <% @group.groupers.each do |grouper| %> + - - - <% end %> - - <% end %> -
UsernameReal NameTask
<%= namelink grouper.user %> <%= h grouper.user.realname %> - <%= g.text_field :task, :size => 20 %> + + <%= form_for grouper do |g| %> +
+ <%= g.text_field :task, size: 20 %> +
+
+ <%= g.submit 'Update', class: 'button tiny' %> + <%= link_to 'Remove', grouper, method: :delete, class: 'button remove' %> +
+ <% end %>
- <%#= link_to_function "Update", "$('edit_grouper_#{grouper.id}').submit()" %> - <%#= link_to "Update", group_path(@group, grouper => { :task => "truc" }), :method => :put %> - <%= g.submit "Update" %> - <%= link_to "Remove", grouper, :method => :delete %> -
+ + <% end %> + - <%= form_for @group.groupers.build do |f| %> - <%= f.hidden_field :group_id %> -

- Add a <%= link_to_function 'user', "findUser('username')" %>: - <%= f.text_field :username %>

- <%= f.label :task %> - <%= f.text_field :task %> - <%= f.submit "Add" %> -

- <% end %> +
+

Add a Member

+ + <%= form_for @group.groupers.build, html: { class: 'square' } do |f| %> + <%= f.hidden_field :group_id %> + +
+ <%= f.label :username %> + <%= f.text_field :username %> +
+ +
+ <%= f.label :task, "Role" %> + <%= f.text_field :task %> +
+ +
+ <%= f.submit 'Add Member' %> +
+ <% end %> +
+
+
-
-
- - -<%= link_to 'Show', @group %> | -<%= link_to 'Back', groups_path %> + +
\ No newline at end of file diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb index 19080cd..707324d 100644 --- a/app/views/groups/index.html.erb +++ b/app/views/groups/index.html.erb @@ -1,26 +1,26 @@ -

Listing groups

+

Listing Groups

- +
- - - - + + + + - <% for group in @groups %> - + <% @groups.each do |group| %> + - <% end %>
NameCreatedFounderOptionsNameCreatedFounder
<%= link_to (h group.name), group %> <%= h group.created_at.strftime("%d %B %y") %> <%= link_to (h group.founder.username), group.founder %> - <%= link_to 'Edit', edit_group_path(group) %> - <%= link_to 'Destroy', group, :confirm => 'Are you sure?', :method => :delete %> + + <%= link_to icon('pencil'), edit_group_path(group) %> + <% if group.can_destroy? cuser %> + <%= link_to icon('times'), group, confirm: 'Are you sure?', method: :delete %> + <% end %>
-
- -<%= link_to 'New group', new_group_path %> +<%= link_to 'New Group', new_group_path, class: 'button' %> diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index 2c718a3..c180eb1 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -1,28 +1,25 @@ -

- <%=h @group.name %> -

+
+

<%=h @group.name %>

+

Founder: <%=h @group.founder.username %>

-

- Founder: - <%=h @group.founder.username %> -

- - - - - - - - - <% for user in @group.users %> - - - - +
UsernameReal NameSteamID
<%=link_to (h user.username), user %><%=h user.firstname %> <%=h user.lastname %><%=h user.steamid %>
+ + + + - <% end %> -
UsernameReal NameSteamID
-<% if cuser and cuser.admin? %> - <%= link_to 'Edit', edit_group_path(@group) %> -<% end %> + <% @group.users.each do |user| %> + + <%=link_to (h user.username), user %> + <%=h user.firstname %> <%=h user.lastname %> + <%=h user.steamid %> + + <% end %> + + + <% if cuser and cuser.admin? %> + <%= link_to 'Edit Group', edit_group_path(@group), class: 'button' %> + <% end %> +
+ \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index f0ab818..7b019e4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -29,6 +29,7 @@ en: scores_recalc: "All scores recalculated." groups_added: "Group added to the list." groups_acl_update: "Group ACL updated." + groups_user_update: "Group member updated." forums_create: "Forum was successfully created." forums_update: "Forum was successfully updated." errors: "Errors: "