From 8e3771305aca4d7fa606c2d43324a19cec56e1d0 Mon Sep 17 00:00:00 2001 From: uu59 Date: Tue, 10 Jun 2014 14:37:24 +0900 Subject: [PATCH] Change recommended plugins page --- app/controllers/plugins_controller.rb | 5 -- app/views/plugins/recommended.html.haml | 65 ++++++++++++++---------- app/views/plugins/recommended2.html.haml | 55 -------------------- 3 files changed, 38 insertions(+), 87 deletions(-) delete mode 100644 app/views/plugins/recommended2.html.haml diff --git a/app/controllers/plugins_controller.rb b/app/controllers/plugins_controller.rb index 1ee4a4b..277f827 100644 --- a/app/controllers/plugins_controller.rb +++ b/app/controllers/plugins_controller.rb @@ -9,11 +9,6 @@ class PluginsController < ApplicationController def recommended @plugins = Plugin.recommended - if params[:v] == "2" - render :recommended2 - else - render :recommended - end end def updated diff --git a/app/views/plugins/recommended.html.haml b/app/views/plugins/recommended.html.haml index e61bb4f..4152e6b 100644 --- a/app/views/plugins/recommended.html.haml +++ b/app/views/plugins/recommended.html.haml @@ -1,33 +1,28 @@ - page_title t('.page_title') -TODO: -= link_to "is this better?", "/plugins/recommended?v=2" - -= form_tag(install_plugins_path, method: :patch) do - %table{class: "table table-striped table-hover", id: "plugins-table"} - %thead +%table{class: "table table-striped table-hover", id: "plugins-table"} + %thead + %tr + %th{width: "24"} + %th= t('.name') + %th= t('.category') + %th= t('.status') + %tbody + - @plugins.each do |plugin| %tr - %th{width: "24"} - %th= t('.name') - %th= t('.category') - %th= t('.status') - %tbody - - @plugins.each do |plugin| - %tr - %td - - unless plugin.installed? - = check_box_tag("plugins[]", plugin.gem_name, false, id: "plugin_#{plugin.gem_name}") - %td - %label{for: "plugin_#{plugin.gem_name}"} - = plugin.gem_name - %td - = plugin.category - %td - - if plugin.installed? - = t(".installed") - - else - = t(".not_installed") - = submit_tag t(".install"), class: "btn btn-primary" + %td + - unless plugin.installed? + = link_to t("terms.install"), install_plugins_path, class: "js-install btn btn-primary", data: { url: install_plugins_path, name: plugin.gem_name} + %td + %label{for: "plugin_#{plugin.gem_name}"} + = plugin.gem_name + %td + = plugin.category + %td + - if plugin.installed? + = t(".installed") + - else + = t(".not_installed") :javascript @@ -41,4 +36,20 @@ TODO: "search": "#{t("terms.search")} " } }); + $('#plugins-table').on('click', '.js-install', function(ev){ + ev.preventDefault(); + var $anchor = $(ev.target); + var url = $anchor.attr('href'); + $anchor.removeClass('js-install'); + $anchor.attr("href", "#"); + $anchor.css({color: "green"}); + var name = $anchor.attr('data-name'); + $.ajax({ + url: url, + data: {"plugins[]": name, "_method": "PATCH"}, + method: "POST" + }).done(function(){ + $anchor.fadeOut(); + });; + }); }); diff --git a/app/views/plugins/recommended2.html.haml b/app/views/plugins/recommended2.html.haml deleted file mode 100644 index 9496448..0000000 --- a/app/views/plugins/recommended2.html.haml +++ /dev/null @@ -1,55 +0,0 @@ -- page_title t('.page_title') - -%table{class: "table table-striped table-hover", id: "plugins-table"} - %thead - %tr - %th{width: "24"} - %th= t('.name') - %th= t('.category') - %th= t('.status') - %tbody - - @plugins.each do |plugin| - %tr - %td - - unless plugin.installed? - = link_to t("terms.install"), install_plugins_path, class: "js-install", data: { url: install_plugins_path, name: plugin.gem_name} - %td - %label{for: "plugin_#{plugin.gem_name}"} - = plugin.gem_name - %td - = plugin.category - %td - - if plugin.installed? - = t(".installed") - - else - = t(".not_installed") - - -:javascript - $(document).ready(function() { - $('#plugins-table').dataTable({ - "ordering": true, - "paging": false, - "info": false, - "searching": true, - "language": { - "search": "#{t("terms.search")} " - } - }); - $('#plugins-table').on('click', '.js-install', function(ev){ - ev.preventDefault(); - var $anchor = $(ev.target); - var url = $anchor.attr('href'); - $anchor.removeClass('js-install'); - $anchor.attr("href", "#"); - $anchor.css({color: "green"}); - var name = $anchor.attr('data-name'); - $.ajax({ - url: url, - data: {"plugins[]": name, "_method": "PATCH"}, - method: "POST" - }).done(function(){ - $anchor.fadeOut(); - });; - }); - });