forked from itskingori/annotator_store-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Daniel
authored and
Daniel
committed
Dec 27, 2021
1 parent
22cd333
commit e97d157
Showing
85 changed files
with
421 additions
and
523 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
6 changes: 6 additions & 0 deletions
6
app/controllers/annotator/discourse_annotator/code_names_controller.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,6 @@ | ||
require_dependency 'annotator/application_controller' | ||
|
||
class Annotator::DiscourseAnnotator::CodeNamesController < Annotator::ApplicationController | ||
|
||
|
||
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
73 changes: 73 additions & 0 deletions
73
app/controllers/annotator/discourse_annotator/localized_codes_controller.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,73 @@ | ||
class Annotator::DiscourseAnnotator::LocalizedCodesController < Annotator::ApplicationController | ||
|
||
|
||
def index | ||
settings = current_user.discourse_annotator_settings | ||
|
||
codes = DiscourseAnnotator::Code | ||
.select('discourse_annotator_codes.id, discourse_annotator_localized_codes.path localized_path') | ||
.order("LOWER(discourse_annotator_localized_codes.path) ASC") | ||
.joins(:localized_codes) | ||
.where(discourse_annotator_localized_codes: {language_id: DiscourseAnnotator::UserSetting.language_for_user(current_user).id}) | ||
|
||
if settings&.discourse_tag.present? | ||
code_ids = DiscourseAnnotator::Annotation.select('DISTINCT code_id') | ||
.where(topic_id: current_user.discourse_annotator_settings.discourse_tag.topics) | ||
codes = codes.where(id: code_ids) | ||
end | ||
|
||
if settings&.propose_codes_from_users.present? | ||
user_ids = settings&.propose_codes_from_users.split.map { |n| User.find_by(username: n)&.id }.compact | ||
user_ids << current_user.id | ||
codes = codes.where(creator_id: user_ids) | ||
elsif settings&.discourse_tag.blank? | ||
codes = codes.where(creator_id: current_user.id) | ||
end | ||
|
||
# codes = codes.where("' ' || discourse_annotator_localized_codes.path ILIKE ?", "% #{params[:q].split.join('%')}%") if params[:q].present? | ||
codes = codes.where("discourse_annotator_localized_codes.path ILIKE ?", "%#{params[:q].split.join('%')}%") if params[:q].present? | ||
|
||
respond_to do |format| | ||
format.json { render json: codes.to_json(fields: %i[code_id localized_path]) } | ||
end | ||
end | ||
|
||
|
||
def mergeable | ||
list | ||
end | ||
|
||
|
||
def autosuggest_codes | ||
list | ||
end | ||
|
||
|
||
private | ||
|
||
def list | ||
codes = DiscourseAnnotator::Code | ||
.joins(:creator) | ||
.joins(:localized_codes) | ||
.select('discourse_annotator_codes.id, users.username username, discourse_annotator_localized_codes.path localized_path') | ||
.order("LOWER(discourse_annotator_localized_codes.path) ASC") | ||
.group(%w[discourse_annotator_codes.id users.username discourse_annotator_localized_codes.path]) | ||
|
||
# Removed. See: https://github.com/edgeryders/discourse-annotator/issues/200 | ||
# .where(discourse_annotator_localized_codes: {language_id: DiscourseAnnotator::UserSetting.language_for_user(current_user).id}) | ||
|
||
codes = codes.where.not(id: params[:code_id]) if params[:code_id].present? | ||
# codes = codes.where("' ' || discourse_annotator_localized_codes.path ILIKE ?", "% #{params[:q].split.join('%')}%") if params[:q].present? | ||
codes = codes.where("discourse_annotator_localized_codes.path ILIKE ?", "%#{params[:q].split.join('%')}%") if params[:q].present? | ||
respond_to do |format| | ||
format.json { | ||
render json: codes.map { |c| | ||
{id: c.id, localized_path: "#{c.localized_path} (by #{c.username})"} | ||
}.to_json | ||
} | ||
end | ||
end | ||
|
||
|
||
end | ||
|
Oops, something went wrong.