-
Notifications
You must be signed in to change notification settings - Fork 15
Threads to be sent to municipality #741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,7 @@ | |
| .meta { | ||
| float:left; | ||
| } | ||
| .permissions { | ||
| .thread-parameters { | ||
| float:right; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| class Admin::ExternalServicesController < ApplicationController | ||
| def index | ||
| @external_services = ExternalService.all | ||
| end | ||
|
|
||
| def new | ||
| @external_service = ExternalService.new | ||
| end | ||
|
|
||
| def create | ||
| @external_service = ExternalService.new(permitted_params) | ||
| puts @external_service | ||
|
|
||
| if @external_service.save | ||
| set_flash_message(:success) | ||
| redirect_to action: :index | ||
| else | ||
| render :new | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| external_service | ||
| end | ||
|
|
||
| def update | ||
| if external_service.update permitted_params | ||
| set_flash_message :success | ||
| redirect_to action: :index | ||
| else | ||
| render :edit | ||
| end | ||
| end | ||
|
|
||
| protected | ||
|
|
||
| def permitted_params | ||
| params.require(:external_service).permit :name, :short_name | ||
| end | ||
|
|
||
| def external_service | ||
| @external_service ||= ExternalService.find params[:id] | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,24 @@ def new | |
| @message = @thread.messages.build | ||
| @message.body = issue.description if issue.threads.count == 0 | ||
| @available_groups = current_user.groups | ||
| @external_services = ExternalService.all | ||
| end | ||
|
|
||
| helper_method :new_external | ||
|
|
||
| def new_external | ||
| @thread = issue.threads.build | ||
| set_page_title nil, issue: issue.title | ||
| if current_group | ||
| @thread.group = current_group | ||
| @thread.privacy = current_group.default_thread_privacy | ||
| end | ||
| @message = @thread.messages.build | ||
| @message.body = issue.description | ||
| @thread.title = issue.title | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about setting the thread title equal to the issue title. etc. See #43 for context. |
||
| @thread.privacy = "public" | ||
| @available_groups = current_user.groups | ||
| @external_services = ExternalService.all | ||
| end | ||
|
|
||
| def create | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: external_services | ||
| # | ||
| # id :integer not null, primary key | ||
| # name :string(255) not null | ||
| # short_name :string(255) not null | ||
| # | ||
| # Indexes | ||
| # | ||
| # index_external_services_on_short_name (short_name) | ||
| # | ||
|
|
||
| class ExternalService < ActiveRecord::Base | ||
| has_many :threads, class_name: 'MessageThread', inverse_of: :external_service | ||
|
|
||
| validates :name, presence: true, uniqueness: true | ||
| validates :short_name, presence: true, uniqueness: true, subdomain: true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this? As in what is the difference between the name and short name? Why not just use the name? |
||
|
|
||
| normalize_attributes :short_name, with: [:strip, :blank, :downcase] | ||
|
|
||
| def to_param | ||
| "#{id}-#{short_name}" | ||
| end | ||
|
|
||
| protected | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason this is here? |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| = semantic_form_for @external_service, url: [:admin, @external_service] do |f| | ||
| = f.inputs do | ||
| = f.input :name, input_html: { size: 30 } | ||
| = f.input :short_name, input_html: { size: 30 } | ||
| = f.actions do | ||
| = f.action :submit, button_html: {class: "btn-green submit"} | ||
| = cancel_link |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| %header | ||
| %h1 | ||
| = t ".edit_external_service" | ||
| %section | ||
| = render "form" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| %header | ||
| %h1= t ".title" | ||
| %section | ||
| .tasks | ||
| %p= link_to t(".new_external_service"), new_admin_external_service_path | ||
| %table | ||
| %thead | ||
| %th= t ".name" | ||
| %th= t ".short_name" | ||
| %tbody | ||
| - @external_services.each do |external_service| | ||
| %tr | ||
| %td= external_service.name | ||
| %td= external_service.short_name | ||
| %td= link_to t(".edit"), [:edit, :admin, external_service] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| %header | ||
| %h1= t ".title" | ||
| %p= t ".introduction" | ||
| %section | ||
| = render "form" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,9 @@ | |
| </ul> | ||
| </div> | ||
| </div> | ||
| <div class="permissions">private</div> | ||
| <div class="thread-parameters"> | ||
| <div class="permissions">private</div> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| <div class="message-count"><span>21</span>replies</div> | ||
|
|
@@ -63,7 +65,9 @@ | |
| </ul> | ||
| </div> | ||
| </div> | ||
| <div class="permissions">private</div> | ||
| <div class="thread-parameters"> | ||
| <div class="permissions">private</div> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| <div class="message-count"><span>13</span>replies</div> | ||
|
|
@@ -79,7 +83,9 @@ | |
| </ul> | ||
| </div> | ||
| </div> | ||
| <div class="permissions">shared</div> | ||
| <div class="thread-parameters"> | ||
| <div class="permissions">shared</div> | ||
| </div> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this whole code is left over from the initial design (i.e. it isn't used live). @mvl22 was there a reason the original designs were kept as part of this repository? Can we delete it? They will exists in git if we do ever need to refer to them.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because the design has never actually been fully implemented yet! That said, I am trying to get round to commissioning a fresh new design that mops up piles of usability issues. |
||
| </li> | ||
| </ul> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| %section.new-thread | ||
| %h2= t ".title", issue: @issue.title.truncate(50) | ||
| - if @issue.threads.count == 0 | ||
| %div.meta | ||
| %p | ||
| %i= simple_format t ".new_hint" | ||
| = semantic_form_for @thread, as: :thread, url: {action: :create}, html: {class: 'guided'} do |f| | ||
| = f.semantic_errors | ||
| = f.inputs do | ||
| = f.input :title | ||
| - if @available_groups.present? | ||
| = f.input :group, | ||
| collection: @available_groups.map {|g| [g.name, g.id, "data-privacy" => g.default_thread_privacy, "data-privacy-options" => Hash[g.thread_privacy_options_map_for(current_user).map { |n,v| [v, n]}].to_json] }, | ||
| include_blank: false | ||
| - if @external_services.present? | ||
| = f.input :external_service, | ||
| as: :select, | ||
| collection: @external_services.map {|g| [g.name, g.id] }, | ||
| include_blank: false | ||
| = semantic_fields_for @message do |f2| | ||
| = f2.semantic_errors | ||
| = f2.input :body, input_html: { rows: 10 } | ||
| = f.actions do | ||
| = f.action :submit, button_html: {class: "btn-green submit", data: { disable_with: t("formtastic.actions.saving") }} | ||
| = cancel_link issue_path(@issue) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,10 @@ | |
| %aside#sidebar.wide | ||
| - if permitted_to? :create, :issue_message_threads | ||
| = link_to t(".new_thread", count: @issue.threads.count), new_issue_thread_path(@issue), class: "btn-green", rel: "#overlay" | ||
| - if current_user and current_user.groups.present? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - if ExternalService.all.present? | ||
| - if permitted_to? :create, :issue_message_threads | ||
| = link_to t(".new_send_thread", count: @issue.threads.count), issue_threads_new_external_path(@issue), class: "btn-green", rel: "#overlay" | ||
| %section.social | ||
| = tweet_button text: @issue.title, link: issue_url(@issue) | ||
| = facebook_like issue_url(@issue) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this after merging.