<%= notice %>
-<%= alert %>
+ +<%= notice %>
+<%= alert %>
+diff --git a/Gemfile b/Gemfile index 151e8ab..a067ce1 100644 --- a/Gemfile +++ b/Gemfile @@ -30,25 +30,18 @@ group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end - -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano', group: :development - -# Use debugger -# gem 'debugger', group: [:development, :test] -# gem 'bootstrap-sass' -# gem 'bootstrap', '~> 4.4.1' gem 'bootstrap-sass' gem 'font-awesome-rails' gem 'popper_js', '~> 1.12.3' -# gem 'dragula-rails' gem 'ffi', '~> 1.9', '>= 1.9.10' gem 'pry', '~> 0.10.3' gem "font-awesome-sass", "~> 6.2.1" - +gem "spring" +gem "spring-commands-rspec" +gem 'ransack' +gem 'kaminari', '~> 0.15.0' +gem 'rubocop-rails', require: false +gem 'paperclip', '~> 3.5' +gem 'remotipart', '~> 1.2' +gem 'friendly_numbers' +gem 'cancancan', '~> 1.17' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index ce224af..e3238da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,6 +26,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 0.3.37) arel (4.0.2) + ast (2.4.2) autoprefixer-rails (9.8.6) execjs bcrypt (3.1.18) @@ -33,6 +34,10 @@ GEM autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.1.4) + cancancan (1.17.0) + climate_control (0.2.0) + cocaine (0.5.8) + climate_control (>= 0.0.3, < 1.0) coderay (1.1.3) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -41,7 +46,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.0) devise (3.5.10) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -56,22 +61,38 @@ GEM railties (>= 3.2, < 8.0) font-awesome-sass (6.2.1) sassc (~> 2.0) + friendly_numbers (0.6.0) hike (1.2.3) i18n (0.9.5) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.4) jbuilder (1.5.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) jquery-rails (3.1.5) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) + kaminari (0.15.1) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) mail (2.7.1) mini_mime (>= 0.1.1) method_source (0.8.2) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) mini_mime (1.1.2) minitest (4.7.5) multi_json (1.15.0) orm_adapter (0.5.0) + paperclip (3.5.4) + activemodel (>= 3.0.0) + activesupport (>= 3.0.0) + cocaine (~> 0.5.3) + mime-types + parallel (1.19.2) + parser (3.2.0.0) + ast (~> 2.4.1) popper_js (1.12.9) pry (0.10.4) coderay (~> 1.1.0) @@ -93,10 +114,31 @@ GEM activesupport (= 4.0.13) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (3.1.1) rake (13.0.6) + ransack (1.8.10) + actionpack (>= 3.0, < 5.2) + activerecord (>= 3.0, < 5.2) + activesupport (>= 3.0, < 5.2) + i18n rdoc (6.2.0) + remotipart (1.4.4) responders (1.1.2) railties (>= 3.2, < 4.2) + rexml (3.2.5) + rubocop (0.81.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.7.0.1) + rainbow (>= 2.2.2, < 4.0) + rexml + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-rails (2.5.2) + activesupport + rack (>= 1.1) + rubocop (>= 0.72.0) + ruby-progressbar (1.11.0) sass (3.2.19) sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) @@ -105,9 +147,12 @@ GEM sprockets-rails (~> 2.0) sassc (2.4.0) ffi (~> 1.9) - sdoc (2.5.0) + sdoc (2.6.0) rdoc (>= 5.0) slop (3.6.0) + spring (1.7.2) + spring-commands-rspec (1.0.4) + spring (>= 0.9.1) sprockets (2.12.5) hike (~> 1.2) multi_json (~> 1.0) @@ -127,6 +172,7 @@ GEM tzinfo (0.3.61) uglifier (4.2.0) execjs (>= 0.3.0, < 3) + unicode-display_width (1.8.0) warden (1.2.7) rack (>= 1.0) @@ -136,19 +182,28 @@ PLATFORMS DEPENDENCIES bcrypt bootstrap-sass + cancancan (~> 1.17) coffee-rails (~> 4.0.0) devise ffi (~> 1.9, >= 1.9.10) font-awesome-rails font-awesome-sass (~> 6.2.1) + friendly_numbers jbuilder (~> 1.2) jquery-rails + kaminari (~> 0.15.0) + paperclip (~> 3.5) popper_js (~> 1.12.3) pry (~> 0.10.3) rails (= 4.0.13) + ransack + remotipart (~> 1.2) + rubocop-rails sass-rails (~> 4.0.2) sassc (~> 2.4.0) sdoc + spring + spring-commands-rspec sqlite3 (~> 1.3.13) thor (= 0.19.1) turbolinks diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 39b94b6..cd7bc78 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,6 +13,7 @@ //= require jquery //= require jquery_ujs //= require popper +//= require turbolinks //* require tree . //= require custom - +//= require jquery.remotipart diff --git a/app/assets/stylesheets/documents.css.scss b/app/assets/stylesheets/documents.css.scss new file mode 100644 index 0000000..e1989fc --- /dev/null +++ b/app/assets/stylesheets/documents.css.scss @@ -0,0 +1,7 @@ +// Place all the styles related to the documents controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.me-3 { + margin-right: 1.5rem!important; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ba523e..f838791 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,12 @@ class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - + before_filter :set_global_search_variable + + def set_global_search_variable + @q = Task.search(params[:q]) + end + rescue_from CanCan::AccessDenied do + flash[:error] = 'Access denied!' + redirect_to root_url + end end diff --git a/app/controllers/board_sections_controller.rb b/app/controllers/board_sections_controller.rb index 355cc0e..173ac56 100644 --- a/app/controllers/board_sections_controller.rb +++ b/app/controllers/board_sections_controller.rb @@ -1,45 +1,52 @@ class BoardSectionsController < ApplicationController - before_action :set_board_section_object, :only=>[:show,:edit,:update,:delete] - before_action :set_board + before_action :set_board_section_object, only: %i[show edit update delete] + before_action :set_board - def index - @board_sections = BoardSection.all - end - def new - @board_section = @board.board_sections.build - end - def show - end - def create - @board_section = @board.board_sections.build(board_section_params) + def index + @board_sections = BoardSection.all + end + + def new + @board_section = @board.board_sections.build + end + + def show; end + + def create + @board_section = @board.board_sections.build(board_section_params) + respond_to do |format| if @board_section.save - redirect_to request.referer + format.js + format.html { redirect_to request.referer } else render :new end end - def edit - end - def update - if @board_section.update(board_section_params) - redirect_to @board_section - else - render :edit - end - end - def delete - @board_section.destroy + end + + def edit; end + + def update + if @board_section.update(board_section_params) redirect_to @board_section + else + render :edit end + end - private - def set_board - @board = Board.find(params[:board_id]) - end - def set_board_section_object - @board_section = BoardSection.find(params[:id]) - end - def board_section_params - params.require(:board_section).permit(:id, :name, :board_type) - end + def delete; end + + private + + def set_board + @board = Board.find(params[:board_id]) + end + + def set_board_section_object + @board_section = BoardSection.find(params[:id]) + end + + def board_section_params + params.require(:board_section).permit(:id, :name, :board_type) + end end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 15af8e9..a9a3703 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -1,25 +1,32 @@ class BoardsController < ApplicationController - before_action :set_board_object, :only=> [:show,:edit,:update,:destroy] - + before_action :set_board_object, only: %i[show edit update destroy] + def index - @boards = Board.all + @boards = Board.all.page(params[:page]) end + def new - @board = Board.new() + @board = Board.new end + def show @board_sections = @board.board_sections end + def create @board = Board.new(board_params) - if @board.save - redirect_to root_path - else - render :new + respond_to do |format| + if @board.save + format.html { redirect_to root_path } + format.js + else + render :new + end end end - def edit - end + + def edit; end + def update if @board.update(board_params) redirect_to @board @@ -27,17 +34,22 @@ def update render :edit end end + def destroy @board.destroy - redirect_to @board + respond_to do |format| + format.js { render layout: false } + format.html { redirect_to @board } + end end private - def board_params - params.require(:board).permit(:id, :name, :board_type,:board_section_is) - end - def set_board_object - @board = Board.find(params[:id]) - end + def board_params + params.require(:board).permit(:id, :name, :board_type, :board_section_id) + end + + def set_board_object + @board = Board.find(params[:id]) + end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 01665c0..2a4f916 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,37 +1,35 @@ class CommentsController < ApplicationController - before_action :set_comment_object :only=>[:show,:edit,:update,:delete] + before_action :set_comment_object, only: %i[show edit update delete] -def index - @comments = Comment.all -end -def new - @comment = Comment.new -end -def show: end -def create - @comment = Comment.create(comment_params) - if @comment.save - redirect_to @comment - else - render :new + def index + @comments = Comment.all end -end -def edit: end -def update - if @comment.update(comment_params) - redirect_to @comment - else - render :edit -end -def delete - @comment.delete - redirect_to @comment -end -private + + def new + @comment = @task.comments.build + end + + def show; end + + def create + @comment = Comment.new(comment_params) + respond_to do |format| + if @comment.save + format.html { redirect_to request.referer } + format.js + else + render :new + end + end + end + + private + def set_comment_object @comment = Comment.find(params[:id]) end + def comment_params - params.require(:comment).permit(:id,:description,:task_id,:user_id) + params.require(:comment).permit(:id, :description, :task_id, :user_id) end end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb new file mode 100644 index 0000000..0675a93 --- /dev/null +++ b/app/controllers/documents_controller.rb @@ -0,0 +1,35 @@ +class DocumentsController < ApplicationController + before_action :set_document_object, only: %i[show edit update delete] + + def index + @documents = Document.all + end + + def new + @document = Document.new + end + + def show; end + + def create + @document = Document.new(document_params) + respond_to do |format| + if @document.save + format.html { redirect_to request.referer } + format.js + else + render :new + end + end + end + + private + + def set_document_object + @document = Document.find(params[:id]) + end + + def document_params + params.require(:document).permit(:file, :task_id) + end +end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 39848c6..b0a59e9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,4 +1,3 @@ class PagesController < ApplicationController - def index - end + def index; end end diff --git a/app/controllers/sub_tasks_controller.rb b/app/controllers/sub_tasks_controller.rb index 5f67ec9..5002244 100644 --- a/app/controllers/sub_tasks_controller.rb +++ b/app/controllers/sub_tasks_controller.rb @@ -1,41 +1,42 @@ class SubTasksController < ApplicationController - before_action :set_subtask_object, :only=> [:edit,:update,:destroy] + before_action :set_subtask_object, only: %i[edit update destroy] def index @subtasks = SubTask.all end + def new @subtask = SubTask.new end + def create @subtask = SubTask.new(subtask_params) - if - @subtask.save + if @subtask.save redirect_to @subtask else render :new end - end + end - def edit; end - - def update - if @subtask.update(subtask_params) - redirect_to @subtask - else - render :edit - end - end - def delete - @subtask.destroy + def edit; end + + def update + if @subtask.update(subtask_params) redirect_to @subtask + else + render :edit end - private - def subtask_params - params.require(:subtask).permit(:id,:name,:description,:status,:due_date,:task_id) - end - def set_subtask_object - @subtask = SubTask.find(params[:id]) - end + end + + def delete; end + + private + def subtask_params + params.require(:subtask).permit(:id, :name, :description, :status, :due_date, :task_id) + end + + def set_subtask_object + @subtask = SubTask.find(params[:id]) + end end diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 3d0d210..98263e5 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -1,22 +1,42 @@ class TasksController < ApplicationController - before_action :set_task_object, :only=> [:edit,:update,:destroy] + load_and_authorize_resource + before_action :set_task, only: %i[show edit update destroy] - def index + def index + @board = Board.find(params[:q][:board]) + @q = Task.ransack(params[:q]) + respond_to do |format| + @board_sections = BoardSection.where(id: @q.result.pluck(:board_section_id)) + format.js + end end + def new @task = Task.new end + + def show + @documents = Document.all + respond_to do |format| + format.js + format.html + end + end + def create - @task = Task.new(task_params) - if - @task.save - redirect_to request.referer - else - render :new + @task = Task.new(task_params) + respond_to do |format| + if @task.save + format.html { redirect_to request.referer } + format.js + else + render :new + end end end - def edit - end + + def edit; end + def update if @task.update(task_params) redirect_to @task @@ -24,16 +44,23 @@ def update render :edit end end - def delete + + def destroy + authorize! :destroy, @task @task.destroy - redirect_to @task + respond_to do |format| + format.js + format.html + end end - + private - def task_params - params.require(:task).permit(:id,:name,:description,:status,:due_date,:story_point,:board_id,:board_section_id) - end - def set_task_object - @task = Task.find(params[:id]) - end + + def task_params + params.require(:task).permit(:id, :name, :description, :status, :due_date, :story_point, :board_id, :board_section_id,:user_id, user_ids: []) + end + + def set_task + @task = Task.find(params[:id]) + end end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb new file mode 100644 index 0000000..242b4fc --- /dev/null +++ b/app/helpers/documents_helper.rb @@ -0,0 +1,2 @@ +module DocumentsHelper +end diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb index ce894d0..1d35c11 100644 --- a/app/helpers/tasks_helper.rb +++ b/app/helpers/tasks_helper.rb @@ -1,2 +1,5 @@ module TasksHelper + def extract_name_from_email(user) + user.email.split('@').first + end end diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 0000000..d4f348b --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,12 @@ +class Ability + include CanCan::Ability + def initialize(user) + if user.present? + can :read, Task + can :create, Task + can :destroy, Task, user_id: user.id + else + can :search, Task + end + end +end \ No newline at end of file diff --git a/app/models/assigned_task.rb b/app/models/assigned_task.rb index 4394dc9..b560edb 100644 --- a/app/models/assigned_task.rb +++ b/app/models/assigned_task.rb @@ -1,4 +1,4 @@ class AssignedTask < ActiveRecord::Base - belongs_to :users - belongs_to :tasks + belongs_to :user + belongs_to :task end diff --git a/app/models/board.rb b/app/models/board.rb index 0bbe70b..88c09fc 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -1,5 +1,6 @@ class Board < ActiveRecord::Base - belongs_to :user - has_many :board_sections - has_many :tasks + paginates_per 3 + belongs_to :user + has_many :board_sections + has_many :tasks end diff --git a/app/models/board_section.rb b/app/models/board_section.rb index e724f6b..c0345f1 100644 --- a/app/models/board_section.rb +++ b/app/models/board_section.rb @@ -1,4 +1,4 @@ class BoardSection < ActiveRecord::Base - belongs_to :board - has_many :tasks + belongs_to :board + has_many :tasks end diff --git a/app/models/comment.rb b/app/models/comment.rb index 6bcd691..29eb3df 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,4 +1,4 @@ class Comment < ActiveRecord::Base - belongs_to :user - belongs_to :task + belongs_to :user + belongs_to :task end diff --git a/app/models/document.rb b/app/models/document.rb new file mode 100644 index 0000000..b9109f8 --- /dev/null +++ b/app/models/document.rb @@ -0,0 +1,5 @@ +class Document < ActiveRecord::Base + belongs_to :task + has_attached_file :file + validates_attachment_content_type :file, content_type: %w(text/plain application/text.txt application/zip application/msword application/vnd.ms-office application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) +end diff --git a/app/models/sub_task.rb b/app/models/sub_task.rb index 0f8f663..7faf554 100644 --- a/app/models/sub_task.rb +++ b/app/models/sub_task.rb @@ -1,3 +1,3 @@ class SubTask < ActiveRecord::Base - belongs_to :task + belongs_to :task end diff --git a/app/models/task.rb b/app/models/task.rb index f68e4a8..d0e85dd 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,8 +1,10 @@ class Task < ActiveRecord::Base - belongs_to :user - belongs_to :board - belongs_to :board_section - has_many :assigned_tasks - has_many :sub_tasks - has_many :comments + belongs_to :user + belongs_to :board + belongs_to :board_section + has_many :assigned_tasks + has_many :users, through: :assigned_tasks + has_many :sub_tasks + has_many :comments + has_many :documents end diff --git a/app/models/user.rb b/app/models/user.rb index 8bc6455..3be037d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,9 +2,9 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable has_many :boards - has_many :tasks has_many :assigned_tasks + has_many :tasks, through: :assigned_tasks has_many :comments devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable -end +end \ No newline at end of file diff --git a/app/views/board_sections/create.js.erb b/app/views/board_sections/create.js.erb new file mode 100644 index 0000000..e3f627c --- /dev/null +++ b/app/views/board_sections/create.js.erb @@ -0,0 +1,3 @@ +$('#add-new-section-modal').modal('toggle'); +$('.board-sections-area').html("<%= escape_javascript render(:partial => 'boards/results', :locals => { board_sections: @board.board_sections, board: @board }) %>"); +$('#board-section-title').val(''); \ No newline at end of file diff --git a/app/views/boards/_board_section.html.erb b/app/views/boards/_board_section.html.erb new file mode 100644 index 0000000..e854aeb --- /dev/null +++ b/app/views/boards/_board_section.html.erb @@ -0,0 +1,8 @@ +
<%= FriendlyNumbers.number_to_human_size(document.file_file_size) %>
++ <%= image_tag "avatar-2.jpg", class:"avatar-xs rounded-circle me-1", alt:"user-img"%> + Robert Carlile +
++ + <%= task.comments.count()%> Comments + +
+Board Name | -Board Type | -Board Created Date | -Actions | -
---|---|---|---|
- <%= link_to b.name, board_path(b) %> - | -- <%= b.board_type%> - | -- <%= b.created_at%> - | -- <%= link_to edit_board_path(b) do %> - - <% end %> - <%= link_to board_path(b), method: :delete, data: { confirm: 'Are you sure?' } do %> - - <% end %> - | -
Board Name | +Board Type | +Board Created Date | +Actions | +
---|
- - Description:<%= task.description%> - -
-<%= notice %>
-<%= alert %>
+ +<%= notice %>
+<%= alert %>
+