forked from joshsoftware/code-curiosity
-
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 joshsoftware#221 from BandanaPandey/royalty_points…
…_validations Added IgnoredFile UI.
- Loading branch information
Showing
18 changed files
with
200 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$(document).on('page:change', function(event) { | ||
|
||
$(function() { | ||
$('#file').bootstrapToggle(); | ||
}) | ||
|
||
$('#file').change(function() { | ||
query = $('#q').val(); | ||
$.ajax({ | ||
type: 'get', | ||
url: '/admin/ignored_files', | ||
data: {'ignored': !($(this).is(':checked')), query: query} | ||
}) | ||
}) | ||
}); |
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,4 @@ | ||
.slide{ | ||
padding-left: 5px; | ||
float: right; | ||
} |
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,67 @@ | ||
class Admin::IgnoredFilesController < ApplicationController | ||
include IgnoredFileHelper | ||
|
||
before_action :authenticate_user! | ||
before_action :authenticate_admin! | ||
before_action :find_ignored_file, except: [:index, :new, :create] | ||
|
||
def index | ||
@status = params[:ignored] ? params[:ignored] : false | ||
|
||
@ignored_files = FileToBeIgnored.where(:ignored => @status, name: /#{params[:query]}/).page(params[:page]) | ||
|
||
if request.xhr? | ||
respond_to do|format| | ||
format.js | ||
end | ||
end | ||
end | ||
|
||
def new | ||
@ignored_file = FileToBeIgnored.new | ||
end | ||
|
||
def create | ||
@ignored_file = FileToBeIgnored.new(files_params) | ||
if @ignored_file.save | ||
redirect_to admin_ignored_files_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @ignored_file.update_attributes(files_params) | ||
redirect_to admin_ignored_files_path | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def search | ||
if params[:q].blank? | ||
redirect_to admin_ignored_files_path | ||
return | ||
end | ||
|
||
@ignored_files = FileToBeIgnored.where(name: /#{params[:q]}/).order(name: :asc) | ||
@ignored_files = @ignored_files.page(1) | ||
render :index | ||
end | ||
|
||
def destroy | ||
@ignored_file.destroy | ||
flash[:success] = "Deleted Successfully" | ||
redirect_to admin_ignored_files_path | ||
end | ||
|
||
private | ||
|
||
def files_params | ||
params.fetch(:file_to_be_ignored).permit(:name, :programming_language, :ignored) | ||
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,7 @@ | ||
module IgnoredFileHelper | ||
|
||
def find_ignored_file | ||
@ignored_file = FileToBeIgnored.where(id: params[:id]).first | ||
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
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,6 @@ | ||
= simple_form_for @ignored_file, url: path do |f| | ||
.col-xs-6 | ||
= f.input :name | ||
= f.input :programming_language | ||
= f.input :ignored, as: :select, collection: { 'Yes' => 'true', 'No' => 'false'}, include_blank: false | ||
%button.btn.btn-primary{type: 'submit'}= @ignored_file.persisted? ? 'Update' : 'Create' |
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,8 @@ | ||
%tr | ||
%td= ignored_file.name | ||
%td= (ignored_file.programming_language).titleize | ||
%td= ignored_file.count | ||
%td= ignored_file.ignored ? 'Yes' : 'No' | ||
%td | ||
= link_to 'Edit', edit_admin_ignored_file_path(ignored_file), class: 'btn btn-xs btn-primary' | ||
= link_to 'Delete', admin_ignored_file_path(ignored_file), class: 'btn btn-xs btn-danger', data: { method: 'delete', confirm: 'Are you sure?' } |
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,9 @@ | ||
%section.content-header | ||
%h1 | ||
Edit File | ||
%section.content | ||
.row | ||
.col-xs-12 | ||
.box.box-primary | ||
.box-body | ||
= render partial: 'form', locals: { path: admin_ignored_file_path(@ignored_file) } |
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,34 @@ | ||
%section.content-header | ||
%h1 | ||
Files | ||
%label.slide | ||
%input.check#file{checked: 'checked', name: 'ignored', type: 'checkbox', data: {toggle: 'toggle', width: '80', height: '34', on: 'Scored', off: 'Ignored'}} | ||
= link_to new_admin_ignored_file_path, class: 'btn btn-success pull-right'do | ||
%b Add File | ||
%section.content | ||
.row | ||
.col-xs-12 | ||
.box.box-primary | ||
.box-header | ||
%h3.box-title | ||
%span Files For Scoring: | ||
.box-tools | ||
= form_tag(search_admin_ignored_files_path, method: :get, class: 'col-xs-4 pull-right') do | ||
.input-group.input-group-sm | ||
= text_field_tag('q', params[:q], class: 'form-control pull-right', placeholder: 'filename/filepath') | ||
.input-group-btn | ||
%button.btn.btn-default{type: 'submit'} Go | ||
.box-body.table-responsive | ||
- if @ignored_files.any? | ||
%table.table.table-bordered | ||
%thead | ||
%tr | ||
%th.col-xs-5 Name/Path | ||
%th.col-xs-3 Programming Language | ||
%th.col-xs-1 Count | ||
%th.col-xs-1 Ignored | ||
%th.col-xs-2 Actions | ||
%tbody#ignored_file | ||
= render partial: 'ignored_file', collection: @ignored_files | ||
.pagination-container | ||
= paginate @ignored_files, remote: true |
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,2 @@ | ||
$('#ignored_file').html("<%=j(render(partial: 'ignored_file', collection: @ignored_files)) %>"); | ||
$(".pagination-container").html("<%=j(paginate @ignored_files, remote: true)%>") |
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,9 @@ | ||
%section.content-header | ||
%h1 | ||
Add File | ||
%section.content | ||
.row | ||
.col-xs-12 | ||
.box.box-primary | ||
.box-body | ||
= render partial: 'form', locals: { path: admin_ignored_files_path } |
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,9 @@ | ||
require "test_helper" | ||
|
||
class Admin::IgnoredFilesControllerTest < ActionController::TestCase | ||
def test_index | ||
skip "need test_cases" | ||
get :index | ||
assert_response :success | ||
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
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