diff --git a/app/views/services/_form.html.erb b/app/views/services/_form.html.erb index d21503aa..0fc45dd5 100644 --- a/app/views/services/_form.html.erb +++ b/app/views/services/_form.html.erb @@ -4,7 +4,7 @@
<%= f.input :name, placeholder: "Service name" %> <%= f.input :url, placeholder: "Address of the service"%> - <%= f.input :privacy_related, as: :boolean, label: :'privacy related' %> + <%= f.input :wikipedia, placeholder: "Wikipedia link" %>
<%= link_to "Back", :back, class: "btn btn-default" %> diff --git a/app/views/services/show.html.erb b/app/views/services/show.html.erb index 2d1476a2..c9269d7a 100644 --- a/app/views/services/show.html.erb +++ b/app/views/services/show.html.erb @@ -2,58 +2,66 @@

<%= @service.name %>

+

+ <%= link_to "Website", service_path(@service.url) %> + <% if @service.wikipedia? %> + <%= link_to "Wikipedia", service_path(@service.wikipedia) %> + <% else %> + Wikipedia + <% end %> +

- + <%= javascript_tag do %> document.getElementById('orderByPoint').addEventListener("click", (event) => { - let elems = document.querySelectorAll(".card-point"); - // convert nodelist to array - var array = []; - for (var i = elems.length >>> 0; i--;) { - array[i] = elems[i]; - } - // perform sort depending on classname - if(event.currentTarget.className=="btn btn-success"){ - array.sort(function(a, b) { - return a.dataset.rating - b.dataset.rating; - }); - event.currentTarget.classList.remove("btn-success"); - event.currentTarget.classList.add("btn-danger"); - } - else if(event.currentTarget.className== "btn btn-danger"){ - array.sort(function(a, b) { - return b.dataset.rating - a.dataset.rating; - }); - event.currentTarget.classList.remove("btn-danger"); - event.currentTarget.classList.add("btn-success"); - } - // join the array back into HTML - var output = ""; - for (var i = 0; i < array.length; i++) { - output += array[i].outerHTML; - } - // append output to div 'points-table-container' - document.getElementById('points-table-container').innerHTML = output; - }); - <% end %> + let elems = document.querySelectorAll(".card-point"); + // convert nodelist to array + var array = []; + for (var i = elems.length >>> 0; i--;) { + array[i] = elems[i]; + } + // perform sort depending on classname + if(event.currentTarget.className=="btn btn-success"){ + array.sort(function(a, b) { + return a.dataset.rating - b.dataset.rating; +}); +event.currentTarget.classList.remove("btn-success"); +event.currentTarget.classList.add("btn-danger"); +} +else if(event.currentTarget.className== "btn btn-danger"){ +array.sort(function(a, b) { +return b.dataset.rating - a.dataset.rating; +}); +event.currentTarget.classList.remove("btn-danger"); +event.currentTarget.classList.add("btn-success"); +} +// join the array back into HTML +var output = ""; +for (var i = 0; i < array.length; i++) { +output += array[i].outerHTML; +} +// append output to div 'points-table-container' +document.getElementById('points-table-container').innerHTML = output; +}); +<% end %> <% if current_user %> - <% if current_user.curator? %> - <%= link_to 'Edit Service', edit_service_path, class: 'btn btn-primary' %> - <%= link_to 'Delete Service', @service, method: :delete, class: 'btn btn-danger' %> - <% end %> +<% if current_user.curator? %> +<%= link_to 'Edit Service', edit_service_path, class: 'btn btn-primary' %> +<%= link_to 'Delete Service', @service, method: :delete, class: 'btn btn-danger' %> +<% end %> -

+

<%= form_tag(service_path(@service), method: :get) do %> - <%= collection_select :topic, :id , Topic.all, :id, :title, {prompt: "Select a Topic"} %> + <%= collection_select :topic, :id , Topic.all, :id, :title, {prompt: "Select a Topic"} %> - <%= submit_tag 'Search', class: "btn btn-default" %> - <%= link_to "Reset", service_path(@service), class: "btn btn-default" %> + <%= submit_tag 'Search', class: "btn btn-default" %> + <%= link_to "Reset", service_path(@service), class: "btn btn-default" %> <% end %>
@@ -95,46 +103,46 @@ <% @points.each do |p| %>
- <% if p.rating.between?(7, 10)%> + <% if p.rating.between?(7, 10)%> <% pointbox = "point-good" %> - <% elsif p.rating.between?(4,6) %> + <% elsif p.rating.between?(4,6) %> <% pointbox = "point-neutral" %> - <% elsif p.rating.between?(2,3) %> + <% elsif p.rating.between?(2,3) %> <% pointbox = "point-bad" %> - <% elsif p.rating.between?(0,2) %> + <% elsif p.rating.between?(0,2) %> <% pointbox = "point-blocker" %> - <% end %> -
-
- <%= p.title %> -
-
- <%= p.rating %> -
-
- <%= p.status %> -
-
- <%= p.topic.title %> -
- -
- <%= link_to(point_path(p), :class => 'btn') do %> - - <% end %> + <% end %> +
+
+ <%= p.title %> +
+
+ <%= p.rating %> +
+
+ <%= p.status %> +
+
+ <%= p.topic.title %> +
+ +
+ <%= link_to(point_path(p), :class => 'btn') do %> + + <% end %> +
-
- <% end %> -
+ <% end %> +
@@ -146,7 +154,7 @@
<%= form_tag(service_path(@service), method: :get) do %> - <%= collection_select :topic, :id , Topic.all, :id, :title, {prompt: "Select a Topic"}, class: "dropdown" %> + <%= collection_select :topic, :id , Topic.all, :id, :title, {prompt: "Select a Topic"}, class: "dropdown" %> <%= submit_tag 'Search', class: "btn btn-default" %> <%= link_to "Reset", service_path(@service), class: "btn btn-default" %> <% end %> @@ -154,10 +162,10 @@
-<% @points.each do |p| %> -
+ <% @points.each do |p| %> +
- <% if p.rating.between?(7, 10)%> + <% if p.rating.between?(7, 10)%> <% pointbox = "point-good" %> <% elsif p.rating.between?(4,6) %> <% pointbox = "point-neutral" %> @@ -165,29 +173,29 @@ <% pointbox = "point-bad" %> <% elsif p.rating.between?(0,2) %> <% pointbox = "point-blocker" %> - <% end %> + <% end %> -
-
-

- <%= p.title %> -

-
+
+
+

+ <%= p.title %> +

+
-
-

- <%= p.analysis %> -

-
+
+

+ <%= p.analysis %> +

+
-
-

- Topic: <%= p.topic.title %> -

-
+
+

+ Topic: <%= p.topic.title %> +

+
-
-
+ +
<% end %>
diff --git a/db/migrate/20171223161343_add_wikipedia_link_to_services.rb b/db/migrate/20171223161343_add_wikipedia_link_to_services.rb new file mode 100644 index 00000000..1d87fc75 --- /dev/null +++ b/db/migrate/20171223161343_add_wikipedia_link_to_services.rb @@ -0,0 +1,5 @@ +class AddWikipediaLinkToServices < ActiveRecord::Migration[5.1] + def change + add_column :services, :wikipedia, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 110cec17..3362166f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171223151948) do +ActiveRecord::Schema.define(version: 20171223161343) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -87,6 +87,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "grade" + t.string "wikipedia" end create_table "topics", force: :cascade do |t|