Skip to content

Commit

Permalink
Merge pull request #37 from Prozak8/cleanup
Browse files Browse the repository at this point in the history
Delete button for hospitals, staffco's and styling
  • Loading branch information
Noelryn committed Nov 16, 2018
2 parents aaf7573 + 3158dd2 commit a30acea
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 18 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ const displayModal = html => {
document.addEventListener('turbolinks:load', () => {
App.mainContent = document.getElementById('main_content')
App.tempContent = document.getElementById('temp_content')

let flashElement = document.getElementById('messages')
setTimeout(()=>{
flashElement.style.display = 'none'
}, 2000);
})
8 changes: 8 additions & 0 deletions app/controllers/hospitals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def create
end
end

def destroy
if Hospital.find(params[:id]).destroy
redirect_to hospitals_path, notice: 'Hospital was successfully removed.'
else
redirect_to hospitals_path, notice: 'Something went wrong, Hospital not removed.'
end
end

private

def hospital_params
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def job_params
:department, :requirements,
:other_requirements, :description,
:years_experience, :application_deadline,
:reference_number
:reference_number, :accomodation_arrangement,
:accomodation_budget, :accomodation_comment,
:travel_arranged, :travel_comment,
:travel_budget, :other_budget,
:other_comment, :other_pay
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def new
def create
build_resource(sign_up_params.except(sign_up_params[:region]))
if resource.save
flash[:notice] = "RSC user #{resource.email} created."
flash[:notice] = "RSC user #{resource.email} created within #{resource.region} region."
sign_up(resource_name, resource)
redirect_to after_sign_in_path_for(resource)
else
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/staffcos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def create
end
end

def destroy
if Staffco.find(params[:id]).destroy
redirect_to staffcos_path, notice: 'Staffing Company was successfully removed.'
else
redirect_to staffcos_path, notice: 'Something went wrong, Staffing Company not removed.'
end
end

private
def staffco_params
params.require(:staffco).permit(:name, :email, :contact_name, :phone, :webhook)
Expand Down
14 changes: 12 additions & 2 deletions app/javascript/css/tailwind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
@tailwind utilities;

#error_messages {
@apply text-red tracking-wide text-sm;
@apply text-red items-center tracking-wide px-4 py-3 text-sm font-bold;
}

#messages {
@apply text-blue border-t border-b border-blue bg-blue-lightest items-center px-4 py-3 text-sm font-bold;
}

.list-card {
Expand Down Expand Up @@ -61,7 +65,13 @@
display: grid;
grid-template-columns: 0.2fr 0.7fr 0.3fr;
grid-template-rows: 1fr;
grid-template-areas: "sidebar content shifts";
grid-template-areas: "sidebar content rightbar";
}

#rightbar {
grid-area: rightbar;
display: grid;
@apply font-sans antialiased h-screen;
}

#sidebar {
Expand Down
4 changes: 1 addition & 3 deletions app/views/hospitals/_index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
.list-grid
.list-name= hospital.name
.list-button-area
%button.button Remove
= link_to "Remove", hospital_path(hospital, locale: I18n.locale), method: :delete, data: {confirm: 'Are you sure?'}, remote: true, class: "button"
= form_with url: hospitals_path, scope: :hospital do |f|
.list-grid
.list-name
= f.text_field :name, id: "Name", class: "form-input-field"
.list-button-area
= f.submit value: "Add Hospital", class: "button text-center"


2 changes: 1 addition & 1 deletion app/views/jobs/new.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ var form = document.getElementById('create_job')
form.addEventListener('ajax:error', (event) => {
let errorMessageDisplayElement = document.getElementById('error_messages')
let message = event.detail[0].message
errorMessageDisplayElement.innerHTML = message
errorMessageDisplayElement.innerHTML = message
})

7 changes: 4 additions & 3 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#content
#temp_content
#main_content
#messages
= notice
= alert
- if notice || alert
#messages
= notice
= alert
= yield
6 changes: 3 additions & 3 deletions app/views/staffcos/_index.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.list-card
.form-header Staffing Companies
.list-item.flex
- @staffcos.each do |staffcos|
- @staffcos.each do |staffco|
.list-grid
.list-name= staffcos.name
.list-name= staffco.name
.list-button-area
%button.button Remove
= link_to "Remove", staffco_path(staffco, locale: I18n.locale), method: :delete, data: {confirm: 'Are you sure?'}, remote: true, class: "button"
.list-button-area
= link_to "Add new company", new_staffco_path, class: "add-button", remote: true
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
root controller: :jobs, action: :index
resources :jobs, only: [:new, :create, :destroy]
resources :invitations, only: [:create, :new]
resources :staffcos, only: [:create, :index, :new]
resources :hospitals, only: [:index, :create, :new]
resources :staffcos, only: [:create, :index, :new, :destroy]
resources :hospitals, only: [:index, :create, :new, :destroy]
resources :regions, only: [:create, :new]
end
end
24 changes: 24 additions & 0 deletions features/rsc_can_delete_a_hospital.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@javascript
Feature: Rsc can delete a hospital
As an RSC,
In order to manage the hospitals list,
I would like to be able to delete hospitals.

Background: On the landing page and can see list of hospitals
Given the following hospitals exists
| name | region |
| karolinska | stockholm |

And the following registered RSC exist
| email | password | region |
| zak@email.com | password0 | stockholm |

And I am logged in as "zak@email.com"
And I am on the landing page
And I click on "Hospitals"

Scenario: Rsc deletes a job
Then I click on "Remove"
And I confirm popup
Then I should see "Hospital was successfully removed."
And I should not see "karolinska"
4 changes: 2 additions & 2 deletions features/rsc_can_delete_a_job.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@javascript
Feature: Rsc can add new job
Feature: Rsc can delete a job
As an RSC,
In order to manage the jobs list,
I would like to be able to delete jobs.

Background: On landing page and can see list of jobs
Background: On the landing page and can see list of jobs
Given the following jobs exist in the database
| profession | region | department | application_deadline | date_start | date_finish |
| Doctor | stockholm | Radiology | 10-01-2019 | 12-12-2018 | 12-12-2019 |
Expand Down
24 changes: 24 additions & 0 deletions features/rsc_can_delete_a_staffing_company.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@javascript
Feature: Rsc can delete a staffing company
As an RSC,
In order to manage the staffing company list,
I would like to be able to delete staffing companies.

Background: On the landing page and can see list of staffing companies
Given the following staffing companies exists
| name | email | region |
| Trib AB | company1@me.com | stockholm |

And the following registered RSC exist
| email | password | region |
| zak@email.com | password0 | stockholm |

And I am logged in as "zak@email.com"
And I am on the landing page
And I click on "Staffing Companies" within the "#sidebar" section

Scenario: Rsc deletes a staffing company
Then I click on "Remove"
And I confirm popup
Then I should see "Staffing Company was successfully removed."
And I should not see "Trib AB"

0 comments on commit a30acea

Please sign in to comment.