-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to share issues with organizations members
- Loading branch information
Showing
20 changed files
with
550 additions
and
18 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
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,6 @@ | ||
class IssuesOrganization < ActiveRecord::Base | ||
|
||
belongs_to :issue | ||
belongs_to :organization | ||
|
||
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,11 @@ | ||
Deface::Override.new :virtual_path => 'issues/_form', | ||
:original => 'ee65ebb813ba3bbf55bc8dc6279f431dbb405c48', | ||
:name => 'add-organizations-to-issue-form', | ||
:insert_after => '.attributes', | ||
:partial => 'issues/select_organizations' | ||
|
||
Deface::Override.new :virtual_path => 'issues/_form_with_positions', | ||
:original => 'ee65ebb813ba3bbf55bc8dc6279f431dbb405c48', | ||
:name => 'add-organizations-to-issue-form', | ||
:insert_after => '.attributes', | ||
:partial => 'issues/select_organizations' |
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 @@ | ||
Deface::Override.new :virtual_path => 'issues/show', | ||
:original => 'ee65ebb813ba3bbf55bc8dc6279f431dbb405c48', | ||
:name => 'show-organizations-in-issue-description', | ||
:insert_after => '.attributes', | ||
:partial => 'issues/show_organizations' |
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,61 @@ | ||
<% if User.current.allowed_to?(:share_issues_with_organizations, @issue.project) %> | ||
|
||
<p id="organizations_form"> | ||
<%= f.select :organization_ids, | ||
options_from_collection_for_select(@issue.organizations, 'id', 'name_with_parents', @issue.organizations.map(&:id)), | ||
{ label: l("field_issue_organizations") }, | ||
{ multiple: true, include_blank: true } | ||
%> | ||
</p> | ||
|
||
<script> | ||
let data = []; | ||
<% @issue.organizations.each do |organization| %> | ||
data.push({id: '<%= organization.id %>', text: '<%= organization.name_with_parents %>'}); | ||
<% end %> | ||
$("#issue_organization_ids").select2({ | ||
containerCss: {width: '500px', minwidth: '500px'}, | ||
width: 'style', | ||
data: data, | ||
minimumInputLength: 3, | ||
language: { | ||
inputTooShort: function () { | ||
return "Entrez au moins 3 caractères"; | ||
}, | ||
noResults: function () { | ||
return "Aucune organisation ne correspond à cette recherche"; | ||
} | ||
}, | ||
ajax: { | ||
url: "/organizations/search.json?key=<%= User.current.api_key %>", | ||
dataType: 'json', | ||
delay: 250, | ||
method: 'GET', | ||
data: function (params) { | ||
return { | ||
organization: params.term | ||
}; | ||
}, | ||
processResults: function (data, params) { | ||
return { | ||
results: data.organizations.map(function (org) { | ||
return { | ||
id: org.id, | ||
text: org.name_with_parents | ||
}; | ||
}) | ||
}; | ||
}, | ||
cache: true | ||
} | ||
}).on('select2:open', function () { | ||
// Forcer le focus dans la zone de texte interne de select2 lorsqu'il s'ouvre | ||
let searchField = $(this).data('select2').dropdown.$search || $(this).data('select2').selection.$search; | ||
if (searchField) { | ||
searchField.focus(); | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% if @issue.organizations.present? %> | ||
<hr> | ||
<label class="label" id="label_related_organizations"><%= l("field_issue_organizations") %></label> | ||
<span class="value"> | ||
<%= @issue.organizations.map { |o| link_to_organization(o, link_ancestors: false, title: o.users.active.map(&:to_s).join(', ')) }.to_sentence.html_safe %> | ||
</span> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
api.array :organizations, api_meta(:total_count => @organizations_count, :offset => @offset, :limit => @limit) do | ||
@organizations.each do |organization| | ||
api.organization do | ||
api.id organization.id | ||
api.name organization.name | ||
api.name_with_parents organization.name_with_parents | ||
api.identifier organization.identifier | ||
|
||
api.created_at organization.created_at | ||
api.updated_at organization.updated_at | ||
end | ||
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
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,16 @@ | ||
class AddOrganizationsToIssues < ActiveRecord::Migration[4.2] | ||
|
||
def self.up | ||
create_table :issues_organizations do |t| | ||
t.column :organization_id, :integer, :null => false | ||
t.column :issue_id, :integer, :null => false | ||
end unless ActiveRecord::Base.connection.table_exists? 'issues_organizations' | ||
add_index :issues_organizations, [:organization_id] unless ActiveRecord::Base.connection.index_exists?(:issues_organizations, [:organization_id]) | ||
add_index :issues_organizations, [:issue_id] unless ActiveRecord::Base.connection.index_exists?(:issues_organizations, [:issue_id]) | ||
end | ||
|
||
def self.down | ||
drop_table :issues_organizations | ||
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
Oops, something went wrong.