Change recommended plugins page

This commit is contained in:
uu59 2014-06-10 14:37:24 +09:00
parent c3ac223149
commit 8e3771305a
3 changed files with 38 additions and 87 deletions

View File

@ -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

View File

@ -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();
});;
});
});

View File

@ -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();
});;
});
});