This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
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.
Merge pull request #214 from OHS-Hosting-Infrastructure/itams_fake
Add fake monitoring link to complaint
- Loading branch information
Showing
26 changed files
with
364 additions
and
87 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
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,31 @@ | ||
class IssueMonitoringReviewsController < ApplicationController | ||
include NeedsHsesAccessToken | ||
|
||
def create | ||
@issue_monitoring_review = IssueMonitoringReview.new( | ||
issue_id: issue_id, | ||
review_id: review_id, | ||
access_token: hses_access_token | ||
) | ||
|
||
respond_to do |format| | ||
if @issue_monitoring_review.save | ||
format.js { render inline: "location.reload(true);" } | ||
else | ||
format.js { render inline: "alert('there was an error linking to a RAN review');" } | ||
# TODO implement when working on error handling | ||
# format.js { render "create_errors" } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def issue_id | ||
params[:issue_id_monitoring] | ||
end | ||
|
||
def review_id | ||
params[:monitoring_review_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,6 @@ def tta_report_display_id | |
end | ||
|
||
def issue_id | ||
params[:issue_id] | ||
params[:issue_id_tta] | ||
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
8 changes: 3 additions & 5 deletions
8
app/models/api/fake_data/itams.rb → app/models/api/fake_data/monitoring.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 |
---|---|---|
@@ -1,18 +1,16 @@ | ||
require "fake_api_response_wrapper" | ||
|
||
class Api::FakeData::Itams | ||
class Api::FakeData::Monitoring | ||
class Review | ||
include FakeApiResponseWrapper | ||
attr_accessor :id | ||
|
||
def initialize(id:) | ||
def initialize(id:, access_token:) | ||
@id = id | ||
end | ||
|
||
def request | ||
details_response( | ||
Api::FakeData::Review.new(id: id).data | ||
) | ||
details_response(Api::FakeData::Review.new(id: id).data) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# TODO remove fake api business once this is hooked up | ||
require "fake_api_response_wrapper" | ||
|
||
module Api::Monitoring | ||
include FakeApiResponseWrapper | ||
attr_accessor :id | ||
|
||
def initialize(id:, access_token:) | ||
@id = id | ||
end | ||
|
||
def request | ||
details_response( | ||
Api::FakeData::MonitoringReview.new(id: id).data | ||
) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
class IssueMonitoringReview < ApplicationRecord | ||
before_validation :retrieve_monitoring_review_details | ||
validates :issue_id, :review_id, :start_date, presence: true | ||
validates :review_id, uniqueness: {scope: :issue_id} | ||
|
||
attr_accessor :access_token | ||
|
||
def monitoring_review | ||
@monitoring_review ||= MonitoringReview.new(review_id, access_token) | ||
end | ||
|
||
private | ||
|
||
def retrieve_monitoring_review_details | ||
if monitoring_review.valid? | ||
self.start_date = monitoring_review.start_date | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "api_delegator" | ||
|
||
class MonitoringReview | ||
attr_accessor :access_token, :id | ||
|
||
def initialize(id, access_token) | ||
@id = id | ||
@access_token = access_token | ||
@errors = [] | ||
end | ||
|
||
def start_date | ||
get_api_data_field :attributes, :reviewStartDate | ||
end | ||
|
||
def valid? | ||
review_data.error.nil? | ||
end | ||
|
||
private | ||
|
||
def api | ||
ApiDelegator.use("monitoring", "review", id: id, access_token: access_token) | ||
end | ||
|
||
def get_api_data_field(*path) | ||
review_data.data.dig(*path) | ||
end | ||
|
||
def review_data | ||
@review_data ||= api.request | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/views/complaints/_complaints_open_new_linked_item.html.erb
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 @@ | ||
<div class="display-flex flex-align-center"> | ||
<%= image_pack_tag "media/usa-icons/link.svg", | ||
class: "ct-link-icon", | ||
id: "#{type}-icon", | ||
"aria-hidden": true | ||
%> | ||
<%= button_to label, "##{type}-id", { | ||
class: "usa-link usa-button--unstyled ct-add-report-link", | ||
id: "js-add-#{type}", | ||
role: "button" | ||
} | ||
%> | ||
</div> |
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,3 @@ | ||
<div class="ct-tta-divider display-flex flex-justify" id="monitoring-activity-show-<%= issue_monitoring_review.id %>"> | ||
<div><%= issue_monitoring_review.review_id %></div> | ||
</div> |
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 |
---|---|---|
@@ -1,23 +1,21 @@ | ||
<div> | ||
<div class="ct-tta-divider display-flex flex-justify" id="tta-activity-show-<%= issue_tta_report.id %>"> | ||
<div><%= issue_tta_report.tta_report_display_id %></div> | ||
<div> | ||
<%= button_tag image_pack_tag("media/usa-icons/edit.svg", alt: "Edit Display ID"), | ||
class: "ct-link-icon usa-button--unstyled js-edit-tta", | ||
"aria-label": "Edit Display ID", | ||
"data-id": issue_tta_report.id | ||
%> | ||
<%= link_to image_pack_tag("media/usa-icons/link_off.svg", alt: "Unlink Display ID"), | ||
"#unlink-modal", | ||
class: "ct-link-icon usa-button--unstyled js-open-unlink-modal", | ||
"aria-controls": "unlink-modal", | ||
"aria-label": "Unlink Display ID", | ||
"data-open-modal": true, | ||
"data-display-id": issue_tta_report.tta_report_display_id | ||
%> | ||
</div> | ||
</div> | ||
<div class="display-none" id="edit-tta-activity-<%= issue_tta_report.id %>"> | ||
<%= render "tta_edit_activity_report", issue_tta_report: issue_tta_report %> | ||
<div class="ct-tta-divider display-flex flex-justify" id="tta-activity-show-<%= issue_tta_report.id %>"> | ||
<div><%= issue_tta_report.tta_report_display_id %></div> | ||
<div> | ||
<%= button_tag image_pack_tag("media/usa-icons/edit.svg", alt: "Edit Display ID"), | ||
class: "ct-link-icon usa-button--unstyled js-edit-tta", | ||
"aria-label": "Edit Display ID", | ||
"data-id": issue_tta_report.id | ||
%> | ||
<%= link_to image_pack_tag("media/usa-icons/link_off.svg", alt: "Unlink Display ID"), | ||
"#unlink-modal", | ||
class: "ct-link-icon usa-button--unstyled js-open-unlink-modal", | ||
"aria-controls": "unlink-modal", | ||
"aria-label": "Unlink Display ID", | ||
"data-open-modal": true, | ||
"data-display-id": issue_tta_report.tta_report_display_id | ||
%> | ||
</div> | ||
</div> | ||
<div class="display-none" id="edit-tta-activity-<%= issue_tta_report.id %>"> | ||
<%= render "tta_edit_activity_report", issue_tta_report: issue_tta_report %> | ||
</div> |
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,19 @@ | ||
<div class="display-none" id="monitoring-activity-form"> | ||
<div class="ct-section-divider"> | ||
<div class="display-flex flex-justify margin-bottom-2"> | ||
<span> RAN ID</span> | ||
<%= button_to "Cancel", "#js-add-monitoring-review", class: "usa-link usa-button--unstyled", id: "js-close-monitoring-form" %> | ||
</div> | ||
<div> | ||
<%= form_with url: issue_monitoring_reviews_path, local: false, method: "post", class: "usa-search display-flex", id: "monitoring-review-form" do %> | ||
<%= hidden_field_tag(:issue_id_monitoring, @complaint.id) %> | ||
<div class="usa-form-group"> | ||
<%= label_tag "monitoring-review-id", "RAN ID", class: "usa-sr-only", id: "monitoring-review-label" %> | ||
<span class="usa-error-message"></span> | ||
<%= text_field_tag :monitoring_review_id, nil, id: "monitoring-review-id", "aria-describedBy": "monitoring-review-label" %> | ||
<%= submit_tag "Link", class: "usa-button usa-search__submit-text", id: "monitoring-review-create-link" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
<div class="ct-section-divider"> | ||
<p> | ||
<div class="display-none" id="tta-activity-form"> | ||
<div class="ct-section-divider"> | ||
<div class="display-flex flex-justify margin-bottom-2"> | ||
<span> Activity Report ID</span> | ||
<%= button_to "Cancel", "#js-add-tta-report", class: "usa-link usa-button--unstyled", id: "js-close-tta-form" %> | ||
</div> | ||
<div> | ||
<%= form_with url: issue_tta_reports_path, local: false, method: "post", class: "usa-search display-flex", id: "tta-report-form" do %> | ||
<%= hidden_field_tag(:issue_id, @complaint.id) %> | ||
<%= hidden_field_tag(:issue_id_tta, @complaint.id) %> | ||
<div class="usa-form-group"> | ||
<%= label_tag "tta-report-display-id", "TTA report display ID", class: "usa-sr-only", id: "tta-report-label" %> | ||
<span class="usa-error-message"></span> | ||
<%= text_field_tag :tta_report_display_id, nil, id: "tta-report-display-id", "aria-describedBy": "tta-report-label" %> | ||
<%= submit_tag "Link", class: "usa-button usa-search__submit-text" %> | ||
<%= submit_tag "Link", class: "usa-button usa-search__submit-text", id: "tta-report-create-link" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</p> | ||
</div> | ||
</div> |
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.