-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f763dee
commit b84da88
Showing
21 changed files
with
214 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ | |
.meta { | ||
float:left; | ||
} | ||
.permissions { | ||
.thread-parameters { | ||
float:right; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
normalize_attributes :short_name, with: [:strip, :blank, :downcase] | ||
|
||
def to_param | ||
"#{id}-#{short_name}" | ||
end | ||
|
||
protected | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
%header | ||
%h1 | ||
= t ".edit_external_service" | ||
%section | ||
= render "form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
%header | ||
%h1= t ".title" | ||
%p= t ".introduction" | ||
%section | ||
= render "form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
db/migrate/20171212101253_add_submit_external_to_message_thread.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddSubmitExternalToMessageThread < ActiveRecord::Migration | ||
def change | ||
add_column :message_threads, :external_service_id, :integer | ||
create_table :external_services do |t| | ||
t.string :name, null: false | ||
t.string :short_name, null: false | ||
end | ||
end | ||
end |