diff --git a/app/controllers/accounts/join_codes_controller.rb b/app/controllers/accounts/join_codes_controller.rb index 52e909de8..b6f08bf3c 100644 --- a/app/controllers/accounts/join_codes_controller.rb +++ b/app/controllers/accounts/join_codes_controller.rb @@ -1,10 +1,10 @@ class Accounts::JoinCodesController < ApplicationController def show - render svg: RQRCode::QRCode.new(join_url(Current.account.join_code)).as_svg(viewbox: true, fill: :white, color: :black) + render svg: RQRCode::QRCode.new(join_url(Account.sole.join_code)).as_svg(viewbox: true, fill: :white, color: :black) end def update - Current.account.reset_join_code - redirect_to account_users_path + Account.sole.reset_join_code + redirect_to users_path end end diff --git a/app/controllers/accounts/users_controller.rb b/app/controllers/accounts/users_controller.rb deleted file mode 100644 index 7243677de..000000000 --- a/app/controllers/accounts/users_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class Accounts::UsersController < ApplicationController - before_action :set_user, only: %i[ update destroy ] - before_action :ensure_permission_to_administer_user, only: %i[ update destroy ] - - def index - @users = Current.account.users.active - end - - def update - @user.update(role_params) - redirect_to account_users_path - end - - def destroy - @user.deactivate - redirect_to account_users_path - end - - private - def set_user - @user = Current.account.users.active.find(params[:id]) - end - - def ensure_permission_to_administer_user - head :forbidden unless Current.user.can_administer?(@user) - end - - def role_params - { role: params.require(:user)[:role].presence_in(%w[ member admin ]) || "member" } - end -end diff --git a/app/controllers/cards/boosts_controller.rb b/app/controllers/cards/boosts_controller.rb deleted file mode 100644 index bebe888fc..000000000 --- a/app/controllers/cards/boosts_controller.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Cards::BoostsController < ApplicationController - include CardScoped - - def create - count = if params[:boost_count].to_i == @card.boosts_count - @card.boosts_count + 1 - else - params[:boost_count].to_i - end - @card.boost!(count) - end -end diff --git a/app/controllers/cards/comments/reactions_controller.rb b/app/controllers/cards/comments/reactions_controller.rb index 00f0ca8a9..fb0c4fa55 100644 --- a/app/controllers/cards/comments/reactions_controller.rb +++ b/app/controllers/cards/comments/reactions_controller.rb @@ -1,42 +1,38 @@ class Cards::Comments::ReactionsController < ApplicationController + include CardScoped + before_action :set_comment def index - @reactions = @comment.reactions.ordered.includes(:reacter) end def new end def create - @reaction = @comment.reactions.create!(reaction_params) + reaction = @comment.reactions.create!(params.expect(reaction: :content)) - broadcast_create - redirect_to card_comment_reactions_url(@comment.card, @comment) + broadcast_create(reaction) + redirect_to card_comment_reactions_path(@card, @comment) end def destroy - @reaction = @comment.reactions.find(params[:id]) - @reaction.destroy! + reaction = @comment.reactions.find(params[:id]) + reaction.destroy - broadcast_remove + broadcast_remove(reaction) end private def set_comment - @comment = Current.account.comments.find(params[:comment_id]) + @comment = Comment.belonging_to_card(@card).find(params[:comment_id]) end - def reaction_params - params.require(:reaction).permit(:content) + def broadcast_create(reaction) + reaction.broadcast_append_to @card, target: [ @comment, :reactions ], partial: "cards/comments/reactions/reaction" end - def broadcast_create - @reaction.broadcast_append_to @reaction.comment, :comments, - target: "reactions_comment_#{@comment.id}", partial: "cards/comments/reactions/reaction", locals: { comment: @comment } - end - - def broadcast_remove - @reaction.broadcast_remove_to @reaction.comment, :comments + def broadcast_remove(reaction) + reaction.broadcast_remove_to @card end end diff --git a/app/controllers/cards/comments_controller.rb b/app/controllers/cards/comments_controller.rb index 4f1745602..33437eb24 100644 --- a/app/controllers/cards/comments_controller.rb +++ b/app/controllers/cards/comments_controller.rb @@ -1,10 +1,11 @@ class Cards::CommentsController < ApplicationController include CardScoped - before_action :set_comment, only: [ :show, :edit, :update, :destroy ] - before_action :require_own_comment, only: [ :edit, :update, :destroy ] + + before_action :set_comment, only: %i[ show edit update destroy ] + before_action :ensure_creatorship, only: %i[ edit update destroy ] def create - @card.capture new_comment + @card.capture Comment.new(comment_params) end def show @@ -23,21 +24,15 @@ class Cards::CommentsController < ApplicationController end private - def comment_params - params.require(:comment).permit(:body) - end - - def new_comment - Comment.new(comment_params) - end - def set_comment - @comment = Comment.joins(:message) - .where(messages: { card_id: @card.id }) - .find(params[:id]) + @comment = Comment.belonging_to_card(@card).find(params[:id]) end - def require_own_comment - head :forbidden unless Current.user == @comment.creator + def ensure_creatorship + head :forbidden if Current.user != @comment.creator + end + + def comment_params + params.expect(comment: :body) end end diff --git a/app/controllers/cards/previews_controller.rb b/app/controllers/cards/previews_controller.rb index f8893266f..aa8877d12 100644 --- a/app/controllers/cards/previews_controller.rb +++ b/app/controllers/cards/previews_controller.rb @@ -1,5 +1,6 @@ class Cards::PreviewsController < ApplicationController include FilterScoped + before_action :set_filter, only: :index def index diff --git a/app/controllers/cards/stagings_controller.rb b/app/controllers/cards/stagings_controller.rb index af524fa52..071d19f5a 100644 --- a/app/controllers/cards/stagings_controller.rb +++ b/app/controllers/cards/stagings_controller.rb @@ -1,11 +1,18 @@ class Cards::StagingsController < ApplicationController include CardScoped + before_action :set_stage + def create - if params[:stage_id].present? - @card.toggle_stage Current.account.stages.find(params[:stage_id]) + if @stage + @card.toggle_stage @stage else @card.update!(stage: nil) end end + + private + def set_stage + @stage = Workflow::Stage.find_by(id: params[:stage_id]) + end end diff --git a/app/controllers/cards/taggings_controller.rb b/app/controllers/cards/taggings_controller.rb index f75681c9d..710b59fdd 100644 --- a/app/controllers/cards/taggings_controller.rb +++ b/app/controllers/cards/taggings_controller.rb @@ -2,7 +2,7 @@ class Cards::TaggingsController < ApplicationController include CardScoped def new - @tags = Current.account.tags.alphabetically + @tags = Tag.all.alphabetically end def create diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index 558f13d69..e62146d4e 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -15,7 +15,8 @@ class CardsController < ApplicationController end def create - redirect_to @collection.cards.create! + card = @collection.cards.create! + redirect_to card end def show @@ -26,7 +27,7 @@ class CardsController < ApplicationController def destroy @card.destroy! - redirect_to cards_path(collection_ids: [ @card.collection ]), notice: deleted_notice + redirect_to cards_path(collection_ids: [ @card.collection ]), notice: ("Card deleted" unless @card.creating?) end def update @@ -50,8 +51,4 @@ class CardsController < ApplicationController def card_params params.expect(card: [ :status, :title, :color, :due_on, :image, :draft_comment, tag_ids: [] ]) end - - def deleted_notice - "Card deleted" unless @card.creating? - end end diff --git a/app/controllers/collections/workflows_controller.rb b/app/controllers/collections/workflows_controller.rb index 963feb595..ae50b90f9 100644 --- a/app/controllers/collections/workflows_controller.rb +++ b/app/controllers/collections/workflows_controller.rb @@ -5,12 +5,11 @@ class Collections::WorkflowsController < ApplicationController def update @collection.update! workflow: @workflow - redirect_to cards_path(collection_ids: [ @collection ]) end private def set_workflow - @workflow = Current.account.workflows.find(params.expect(collection: [ :workflow_id ]).require(:workflow_id)) + @workflow = Workflow.find(params.expect(collection: [ :workflow_id ]).require(:workflow_id)) end end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 3eb8cb507..36698afdf 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -2,11 +2,11 @@ class CollectionsController < ApplicationController before_action :set_collection, except: %i[ new create ] def new - @collection = Current.account.collections.build + @collection = Collection.new end def create - @collection = Current.account.collections.create! collection_params + @collection = Collection.create! collection_params redirect_to cards_path(collection_ids: [ @collection ]) end @@ -37,7 +37,7 @@ class CollectionsController < ApplicationController end def grantees - Current.account.users.active.where id: grantee_ids + User.active.where id: grantee_ids end def revokees diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index b097025c0..68e729f02 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -40,7 +40,7 @@ module Authentication def request_authentication session[:return_to_after_authenticating] = request.url - redirect_to new_session_url + redirect_to new_session_path end def after_authentication_url diff --git a/app/controllers/concerns/card_scoped.rb b/app/controllers/concerns/card_scoped.rb index e85291b57..ef40d56e3 100644 --- a/app/controllers/concerns/card_scoped.rb +++ b/app/controllers/concerns/card_scoped.rb @@ -11,6 +11,6 @@ module CardScoped end def set_collection - @collection = Current.user.collections.find(@card.collection_id) + @collection = @card.collection end end diff --git a/app/controllers/concerns/events_timeline.rb b/app/controllers/concerns/events_timeline.rb index d71928b4d..0d50d2093 100644 --- a/app/controllers/concerns/events_timeline.rb +++ b/app/controllers/concerns/events_timeline.rb @@ -19,13 +19,9 @@ module EventsTimeline end def events_for_activity_day - user_events.where(created_at: @activity_day.all_day). - group_by { |event| [ event.created_at.hour, helpers.event_column(event) ] }. - map { |hour_col, events| - [ hour_col, - events.uniq { |e| e.action == "boosted" ? [ e.creator_id, e.card_id ] : e.id } - ] - } + user_events.where(created_at: @activity_day.all_day) + .group_by { |event| [ event.created_at.hour, helpers.event_column(event) ] } + .map { |hour_col, events| [ hour_col, events.uniq { |e| e.id } ] } end def latest_event_before_activity_day @@ -33,12 +29,12 @@ module EventsTimeline end def user_events - Event.where(card: user_cards, creator: Current.account.users) + Event.where(card: user_cards) end def user_cards Current.user.accessible_cards - .published_or_drafted_by(Current.user) - .where(collection_id: collection_filter) + .published_or_drafted_by(Current.user) + .where(collection_id: collection_filter) end end diff --git a/app/controllers/concerns/workflow_scoped.rb b/app/controllers/concerns/workflow_scoped.rb index ca2e7398c..8e358733a 100644 --- a/app/controllers/concerns/workflow_scoped.rb +++ b/app/controllers/concerns/workflow_scoped.rb @@ -7,6 +7,6 @@ module WorkflowScoped private def set_workflow - @workflow = Current.account.workflows.find params[:workflow_id] + @workflow = Workflow.find(params[:workflow_id]) end end diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb index 6c840952a..ba34c1622 100644 --- a/app/controllers/filters_controller.rb +++ b/app/controllers/filters_controller.rb @@ -8,7 +8,12 @@ class FiltersController < ApplicationController def destroy @filter.destroy! - redirect_after_destroy + + if request.referer == root_url + redirect_to root_path + else + redirect_to cards_path(@filter.as_params) + end end private @@ -19,12 +24,4 @@ class FiltersController < ApplicationController def filter_params params.permit(*Filter::PERMITTED_PARAMS).compact_blank end - - def redirect_after_destroy - if request.referer == root_url - redirect_to root_path - else - redirect_to cards_path(@filter.as_params) - end - end end diff --git a/app/controllers/first_runs_controller.rb b/app/controllers/first_runs_controller.rb index 6b59db593..e13b91b76 100644 --- a/app/controllers/first_runs_controller.rb +++ b/app/controllers/first_runs_controller.rb @@ -7,17 +7,13 @@ class FirstRunsController < ApplicationController end def create - user = FirstRun.create!(user_params) + user = FirstRun.create!(params.expect(user: [ :name, :email_address, :password ])) start_new_session_for user redirect_to root_path end private def prevent_repeats - redirect_to root_path unless Account.none? - end - - def user_params - params.expect(user: [ :name, :email_address, :password ]) + redirect_to root_path if Account.any? end end diff --git a/app/controllers/qr_codes_controller.rb b/app/controllers/qr_codes_controller.rb index 707166930..42917d64b 100644 --- a/app/controllers/qr_codes_controller.rb +++ b/app/controllers/qr_codes_controller.rb @@ -2,10 +2,7 @@ class QrCodesController < ApplicationController allow_unauthenticated_access def show - qr_code_link = QrCodeLink.from_signed(params[:id]) - svg = RQRCode::QRCode.new(qr_code_link.url).as_svg(viewbox: true, fill: :white, color: :black) - expires_in 1.year, public: true - render plain: svg, content_type: "image/svg+xml" + render svg: RQRCode::QRCode.new(QrCodeLink.from_signed(params[:id]).url).as_svg(viewbox: true, fill: :white, color: :black) end end diff --git a/app/controllers/terminals_controller.rb b/app/controllers/terminals_controller.rb index d05a339bc..728ff9983 100644 --- a/app/controllers/terminals_controller.rb +++ b/app/controllers/terminals_controller.rb @@ -1,14 +1,9 @@ class TerminalsController < ApplicationController def show - @events = Event.where(card: user_cards, creator: Current.user).chronologically.reverse_order.limit(20) + @events = Event.where(card: Current.user.accessible_cards, creator: Current.user).chronologically.reverse_order.limit(20) end def edit @filter = Current.user.filters.from_params params.permit(*Filter::PERMITTED_PARAMS) end - - private - def user_cards - Current.user.accessible_cards - end end diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 1c2af5a53..a6f4cab39 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -5,7 +5,8 @@ class UploadsController < ApplicationController before_action :set_attachment, only: :show def create - @upload = Current.account.uploads_attachments.create! blob: create_blob! + # FIXME: Try to get upload attachments on root + @upload = Account.sole.uploads_attachments.create! blob: create_blob! end def show diff --git a/app/controllers/users/avatars_controller.rb b/app/controllers/users/avatars_controller.rb index e48a1f7f2..46deb691e 100644 --- a/app/controllers/users/avatars_controller.rb +++ b/app/controllers/users/avatars_controller.rb @@ -24,7 +24,7 @@ class Users::AvatarsController < ApplicationController end def set_user - @user = Current.account.users.find(params[:user_id]) + @user = User.find(params[:user_id]) end def render_avatar_or_initials diff --git a/app/controllers/users/roles_controller.rb b/app/controllers/users/roles_controller.rb new file mode 100644 index 000000000..8cffa232b --- /dev/null +++ b/app/controllers/users/roles_controller.rb @@ -0,0 +1,22 @@ +class Users::RolesController < ApplicationController + before_action :set_user + before_action :ensure_permission_to_administer_user + + def update + @user.update(role_params) + redirect_to users_path + end + + private + def set_user + @user = User.active.find(params[:user_id]) + end + + def ensure_permission_to_administer_user + head :forbidden unless Current.user.can_administer?(@user) + end + + def role_params + { role: params.require(:user)[:role].presence_in(%w[ member admin ]) || "member" } + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 32e5c340c..4069e5aaa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,15 +1,20 @@ class UsersController < ApplicationController require_unauthenticated_access only: %i[ new create ] - before_action :set_user, only: %i[ show edit update ] + before_action :set_user, only: %i[ show edit update destroy ] before_action :set_account_from_join_code, only: %i[ new create ] + before_action :ensure_permission_to_administer_user, only: %i[ update destroy ] + + def index + @users = User.active + end def new - @user = @account.users.build + @user = User.new end def create - user = @account.users.create!(user_params) + user = User.create!(user_params) start_new_session_for user redirect_to root_path end @@ -21,8 +26,13 @@ class UsersController < ApplicationController end def update - @user.update user_params - redirect_to user_path(@user) + @user.update! user_params + redirect_to @user + end + + def destroy + @user.deactivate + redirect_to users_path end private @@ -31,7 +41,11 @@ class UsersController < ApplicationController end def set_user - @user = Current.account.users.active.find(params[:id]) + @user = User.active.find(params[:id]) + end + + def ensure_permission_to_administer_user + head :forbidden unless Current.user.can_administer?(@user) end def user_params diff --git a/app/controllers/workflows/stages_controller.rb b/app/controllers/workflows/stages_controller.rb index f6422f9d6..5973948d2 100644 --- a/app/controllers/workflows/stages_controller.rb +++ b/app/controllers/workflows/stages_controller.rb @@ -9,7 +9,7 @@ class Workflows::StagesController < ApplicationController def create @stage = @workflow.stages.create! stage_params - redirect_to workflow_path(@workflow) + redirect_to @workflow end def edit @@ -17,12 +17,12 @@ class Workflows::StagesController < ApplicationController def update @stage.update! stage_params - redirect_to workflow_path(@workflow) + redirect_to @workflow end def destroy @stage.destroy - redirect_to workflow_path(@workflow) + redirect_to @workflow end private diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 390cedcdb..49abcd26f 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -2,15 +2,15 @@ class WorkflowsController < ApplicationController before_action :set_workflow, only: %i[ show edit update destroy ] def index - @workflows = Current.account.workflows + @workflows = Workflow.all end def new - @workflow = Current.account.workflows.new + @workflow = Workflow.new end def create - @workflow = Current.account.workflows.create! workflow_params + @workflow = Workflow.create! workflow_params # FIXME: this should definitely change. [ "Triage", "In progress", "On Hold", "Review" ].each { |name| @workflow.stages.create! name: name } redirect_to workflows_path @@ -24,7 +24,7 @@ class WorkflowsController < ApplicationController def update @workflow.update! workflow_params - redirect_to workflow_path(@workflow) + redirect_to @workflow end def destroy @@ -34,10 +34,10 @@ class WorkflowsController < ApplicationController private def set_workflow - @workflow = Current.account.workflows.find params[:id] + @workflow = Workflow.find params[:id] end def workflow_params - params.expect workflow: [ :name ] + params.expect workflow: :name end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a4d9e9ec5..52783033c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,9 +4,6 @@ module ApplicationHelper end def icon_tag(name, **options) - classes = class_names "icon icon--#{name}", options.delete(:class) - options["aria-hidden"] = true - - content_tag :span, "", class: classes, **options + tag.span class: class_names("icon icon--#{name}", options.delete(:class)), "aria-hidden": true, **options end end diff --git a/app/helpers/cards_helper.rb b/app/helpers/cards_helper.rb index 1546efd8e..e13defa96 100644 --- a/app/helpers/cards_helper.rb +++ b/app/helpers/cards_helper.rb @@ -1,16 +1,4 @@ module CardsHelper - CARD_ROTATION = %w[ 75 60 45 35 25 5 ] - - def card_title(card) - card.title.presence || "Untitled" - end - - def card_rotation(card) - value = CARD_ROTATION[Zlib.crc32(card.to_param) % CARD_ROTATION.size] - - "--card-rotate: #{value}deg;" - end - def cards_next_page_link(target, page:, filter:, fetch_on_visible: false, data: {}, **options) url = cards_previews_path(target: target, page: page.next_param, **filter.as_params) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 77847b53b..122e8d551 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -1,9 +1,4 @@ module CommentsHelper - def comment_tag(comment, &) - tag.div id: dom_id(comment), class: "comment flex align-start full-width", - data: { creator_id: comment.creator_id, created_by_current_user_target: "creation" }, & - end - def new_comment_placeholder(card) if card.creator == Current.user && card.messages.comments.empty? "Next, add some notes, context, pictures, or video about this…" diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 4af17cbb0..53732b327 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -66,32 +66,30 @@ module EventsHelper case event.action when "assigned" if event.assignees.include?(Current.user) - "#{ event.creator == Current.user ? "You" : event.creator.name } will handle #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } will handle #{ event.card.title }".html_safe else - "#{ event.creator == Current.user ? "You" : event.creator.name } assigned #{ event.assignees.pluck(:name).to_sentence } to #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } assigned #{ event.assignees.pluck(:name).to_sentence } to #{ event.card.title }".html_safe end when "unassigned" - "#{ event.creator == Current.user ? "You" : event.creator.name } unassigned #{ event.assignees.include?(Current.user) ? "yourself" : event.assignees.pluck(:name).to_sentence } from #{ card_title(event.card) }".html_safe - when "boosted" - "#{ event.creator == Current.user ? "You" : event.creator.name } boosted #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } unassigned #{ event.assignees.include?(Current.user) ? "yourself" : event.assignees.pluck(:name).to_sentence } from #{ event.card.title }".html_safe when "commented" - "#{ event.creator == Current.user ? "You" : event.creator.name } commented on #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } commented on #{ event.card.title }".html_safe when "published" - "#{ event.creator == Current.user ? "You" : event.creator.name } added #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } added #{ event.card.title }".html_safe when "closed" - "#{ event.creator == Current.user ? "You" : event.creator.name } closed #{ card_title(event.card) }".html_safe + "#{ event.creator == Current.user ? "You" : event.creator.name } closed #{ event.card.title }".html_safe when "staged" - "#{event.creator == Current.user ? "You" : event.creator.name} moved #{ card_title(event.card) } to the #{event.stage_name} stage".html_safe + "#{event.creator == Current.user ? "You" : event.creator.name} moved #{ event.card.title } to the #{event.stage_name} stage".html_safe when "unstaged" - "#{event.creator == Current.user ? "You" : event.creator.name} moved #{ card_title(event.card) } out ofthe #{event.stage_name} stage".html_safe + "#{event.creator == Current.user ? "You" : event.creator.name} moved #{ event.card.title } out ofthe #{event.stage_name} stage".html_safe when "due_date_added" - "#{event.creator == Current.user ? "You" : event.creator.name} set the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on #{ card_title(event.card) }".html_safe + "#{event.creator == Current.user ? "You" : event.creator.name} set the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on #{ event.card.title }".html_safe when "due_date_changed" - "#{event.creator == Current.user ? "You" : event.creator.name} changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on #{ card_title(event.card) }".html_safe + "#{event.creator == Current.user ? "You" : event.creator.name} changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')} on #{ event.card.title }".html_safe when "due_date_removed" - "#{event.creator == Current.user ? "You" : event.creator.name} removed the date on #{ card_title(event.card) }" + "#{event.creator == Current.user ? "You" : event.creator.name} removed the date on #{ event.card.title }" when "title_changed" - "#{event.creator == Current.user ? "You" : event.creator.name} renamed #{ card_title(event.card) } (was: '#{event.particulars.dig('particulars', 'old_title')})'".html_safe + "#{event.creator == Current.user ? "You" : event.creator.name} renamed #{ event.card.title } (was: '#{event.particulars.dig('particulars', 'old_title')})'".html_safe end end @@ -99,8 +97,6 @@ module EventsHelper case event.action when "assigned" "assigned" - when "boosted" - "thumb-up" when "staged" "bolt" when "unstaged" diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb index a8a7544ac..9dae7757c 100644 --- a/app/helpers/messages_helper.rb +++ b/app/helpers/messages_helper.rb @@ -2,7 +2,7 @@ module MessagesHelper def messages_tag(card, &) turbo_frame_tag dom_id(card, :messages), class: "comments gap center", - style: "--card-color: <%= card.color %>", + style: "--card-color: #{card.color}", role: "group", aria: { label: "Messages" }, data: { controller: "created-by-current-user", diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 12bc5f745..0b30ce9cb 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,11 +1,9 @@ module NotificationsHelper def notification_title(notification) - title = card_title(notification.card) - if notification.resource.is_a? Comment - "RE: " + title + "RE: " + notification.card.title elsif notification_event_action(notification) == "assigned" - "Assigned to you: " + title + "Assigned to you: " + notification.card.title else title end diff --git a/app/models/account.rb b/app/models/account.rb index 10ba9f773..f562ef665 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,21 +1,5 @@ class Account < ApplicationRecord - include ClosureReasons, Joinable - - has_many :collections, dependent: :destroy - has_many :cards, through: :collections - - has_many :users, dependent: :destroy do - def system - find_or_create_system_user(proxy_association.owner) - end - end - - has_many :comments, through: :users - - has_many :workflows, dependent: :destroy - has_many :stages, through: :workflows, class_name: "Workflow::Stage" - - has_many :tags, dependent: :destroy + include Joinable has_many_attached :uploads end diff --git a/app/models/account/closure_reasons.rb b/app/models/account/closure_reasons.rb deleted file mode 100644 index e5bdf25a1..000000000 --- a/app/models/account/closure_reasons.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Account::ClosureReasons - extend ActiveSupport::Concern - - DEFAULT_LABELS = [ - "Completed", - "Duplicate", - "Maybe later", - "Working as intended" - ] - - FALLBACK_LABEL = "Done" - - included do - has_many :closure_reasons, dependent: :destroy, class_name: "Closure::Reason" do - def labels - pluck(:label).presence || [ FALLBACK_LABEL ] - end - end - - after_create :create_default_closure_reasons - end - - private - def create_default_closure_reasons - DEFAULT_LABELS.each do |label| - closure_reasons.create! label: label - end - end -end diff --git a/app/models/card.rb b/app/models/card.rb index 8d4411cf4..e2191aa41 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -1,5 +1,5 @@ class Card < ApplicationRecord - include Assignable, Boostable, Colored, Commentable, Engageable, Eventable, Golden, + include Assignable, Colored, DraftCommenting, Engageable, Eventable, Golden, Messages, Notifiable, Pinnable, Closeable, Scorable, Searchable, Staged, Statuses, Taggable, Watchable @@ -22,8 +22,6 @@ class Card < ApplicationRecord scope :indexed_by, ->(index) do case index when "most_active" then ordered_by_activity - when "most_discussed" then ordered_by_comments - when "most_boosted" then ordered_by_boosts when "newest" then reverse_chronologically when "oldest" then chronologically when "latest" then latest @@ -39,6 +37,10 @@ class Card < ApplicationRecord end end + def title=(new_title) + self[:title] = new_title.presence || "Untitled" + end + def cache_key [ super, collection&.name ].compact.join("/") end diff --git a/app/models/card/boostable.rb b/app/models/card/boostable.rb deleted file mode 100644 index 9e7c404c8..000000000 --- a/app/models/card/boostable.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Card::Boostable - extend ActiveSupport::Concern - - included do - scope :ordered_by_boosts, -> { order boosts_count: :desc } - end - - def boost!(count = 1) - count = count.to_i - count = 1 if count < 1 - - transaction do - track_event :boosted, count: count - update! boosts_count: count - rescore - end - end -end diff --git a/app/models/card/closeable.rb b/app/models/card/closeable.rb index 3f98cb719..ce0a63e33 100644 --- a/app/models/card/closeable.rb +++ b/app/models/card/closeable.rb @@ -16,7 +16,7 @@ module Card::Closeable class_methods do def auto_close_all_due due_to_be_closed.find_each do |card| - card.close(user: card.collection.account.users.system, reason: "Closed") + card.close(user: User.system, reason: "Closed") end end end @@ -41,7 +41,7 @@ module Card::Closeable closure&.created_at end - def close(user: Current.user, reason: Account::ClosureReasons::FALLBACK_LABEL) + def close(user: Current.user, reason: Closure::Reason::FALLBACK_LABEL) unless closed? transaction do create_closure! user: user, reason: reason diff --git a/app/models/card/commentable.rb b/app/models/card/commentable.rb deleted file mode 100644 index d0308069f..000000000 --- a/app/models/card/commentable.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Card::Commentable - extend ActiveSupport::Concern - - included do - scope :ordered_by_comments, -> { order comments_count: :desc } - end - - def comment_created(comment) - increment! :comments_count - watch_by comment.creator - - track_event :commented, comment_id: comment.id - rescore - end - - def comment_destroyed - decrement! :comments_count - rescore - end -end diff --git a/app/models/card/draft_commenting.rb b/app/models/card/draft_commenting.rb new file mode 100644 index 000000000..615d23916 --- /dev/null +++ b/app/models/card/draft_commenting.rb @@ -0,0 +1,33 @@ +module Card::DraftCommenting + extend ActiveSupport::Concern + + included do + after_save :capture_draft_comment + end + + def draft_comment + find_or_build_initial_comment.body.content + end + + def draft_comment=(body) + if body.present? + @draft_comment = body + else + messages.comments.destroy_all + end + end + + private + def find_or_build_initial_comment + message = messages.comments.first || messages.new(messageable: Comment.new) + message.comment + end + + def capture_draft_comment + if @draft_comment.present? + find_or_build_initial_comment.update! body: @draft_comment, creator: creator + end + + @draft_comment = nil + end +end diff --git a/app/models/card/eventable.rb b/app/models/card/eventable.rb index 038a6d51a..c8098708b 100644 --- a/app/models/card/eventable.rb +++ b/app/models/card/eventable.rb @@ -10,14 +10,14 @@ module Card::Eventable touch :last_active_at end - private - def track_event(action, creator: Current.user, **particulars) - if published? - event = find_or_capture_event_summary.events.create! action: action, creator: creator, card: self, particulars: particulars - event.generate_notifications_later - end + def track_event(action, creator: Current.user, **particulars) + if published? + event = find_or_capture_event_summary.events.create! action: action, creator: creator, card: self, particulars: particulars + event.generate_notifications_later end + end + private def find_or_capture_event_summary transaction do messages.last&.event_summary || capture(EventSummary.new).event_summary diff --git a/app/models/card/messages.rb b/app/models/card/messages.rb index 01446905c..89579b78f 100644 --- a/app/models/card/messages.rb +++ b/app/models/card/messages.rb @@ -3,35 +3,9 @@ module Card::Messages included do has_many :messages, -> { chronologically }, dependent: :destroy - after_save :capture_draft_comment end def capture(messageable) messages.create! messageable: messageable end - - def draft_comment - find_or_build_initial_comment.body.content - end - - def draft_comment=(body) - if body.present? - @draft_comment = body - else - messages.comments.destroy_all - end - end - - private - def find_or_build_initial_comment - message = messages.comments.first || messages.new(messageable: Comment.new) - message.comment - end - - def capture_draft_comment - if @draft_comment.present? - find_or_build_initial_comment.update! body: @draft_comment, creator: creator - end - @draft_comment = nil - end end diff --git a/app/models/card/scorable.rb b/app/models/card/scorable.rb index 3bad86a74..91b0856b5 100644 --- a/app/models/card/scorable.rb +++ b/app/models/card/scorable.rb @@ -36,7 +36,6 @@ module Card::Scorable def event_weight(event) case - when event.boosted? then 1 when event.comment&.first_by_author_on_card? then 20 when event.comment&.follows_comment_by_another_author? then 15 when event.commented? then 10 @@ -60,6 +59,6 @@ module Card::Scorable end def scorable_events - events.where(action: [ :commented, :boosted ]) + events.where(action: :commented) end end diff --git a/app/models/card/taggable.rb b/app/models/card/taggable.rb index a419a4cae..5ad75a593 100644 --- a/app/models/card/taggable.rb +++ b/app/models/card/taggable.rb @@ -9,7 +9,7 @@ module Card::Taggable end def toggle_tag_with(title) - tag = collection.account.tags.find_or_create_by!(title: title) + tag = Tag.find_or_create_by!(title: title) transaction do if tagged_with?(tag) diff --git a/app/models/closure/reason.rb b/app/models/closure/reason.rb index aa1f0161b..1472d09d1 100644 --- a/app/models/closure/reason.rb +++ b/app/models/closure/reason.rb @@ -1,3 +1,22 @@ class Closure::Reason < ApplicationRecord - belongs_to :account + DEFAULT_LABELS = [ + "Completed", + "Duplicate", + "Maybe later", + "Working as intended" + ] + + FALLBACK_LABEL = "Done" + + class << self + def labels + pluck(:label).presence || [ FALLBACK_LABEL ] + end + + def create_defaults + DEFAULT_LABELS.each do |label| + create! label: label + end + end + end end diff --git a/app/models/collection.rb b/app/models/collection.rb index 3820af5a1..319b2bb7d 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,7 +1,6 @@ class Collection < ApplicationRecord include Accessible, Broadcastable, Filterable - belongs_to :account belongs_to :creator, class_name: "User", default: -> { Current.user } belongs_to :workflow, optional: true diff --git a/app/models/collection/accessible.rb b/app/models/collection/accessible.rb index 81ed9b5b1..fc99cc217 100644 --- a/app/models/collection/accessible.rb +++ b/app/models/collection/accessible.rb @@ -34,6 +34,6 @@ module Collection::Accessible private def grant_access_to_everyone - accesses.grant_to(account.users) if all_access_previously_changed?(to: true) + accesses.grant_to(User.all) if all_access_previously_changed?(to: true) end end diff --git a/app/models/collection/broadcastable.rb b/app/models/collection/broadcastable.rb index 5e36898d6..f3f2f398e 100644 --- a/app/models/collection/broadcastable.rb +++ b/app/models/collection/broadcastable.rb @@ -3,6 +3,6 @@ module Collection::Broadcastable included do broadcasts_refreshes - broadcasts_refreshes_to ->(collection) { [ collection.account, :collections ] } + broadcasts_refreshes_to ->(_) { :collections } end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 519fc9a72..8922b30b7 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,43 +1,34 @@ class Comment < ApplicationRecord - include Messageable, Notifiable, Searchable + include Messageable, Searchable belongs_to :creator, class_name: "User", default: -> { Current.user } - has_many :reactions, dependent: :destroy - - searchable_by :body_plain_text, using: :comments_search_index, as: :body + has_many :reactions, dependent: :delete_all has_markdown :body + searchable_by :body_plain_text, using: :comments_search_index, as: :body - before_destroy :cleanup_events + # FIXME: Not a fan of this. Think all references to comment should come directly from the message. + scope :belonging_to_card, ->(card) { joins(:message).where(messages: { card_id: card.id }) } - def first_by_author_on_card? - card_comments.many? && card_comments_prior.where(creator_id: creator_id).none? - end - - def follows_comment_by_another_author? - card_comments.many? && card_comments_prior.last&.creator != creator - end + after_create_commit :watch_card_by_creator, :track_commented_card + after_destroy_commit :cleanup_events def to_partial_path "cards/#{super}" end private - def cleanup_events - # Delete events that reference through event_summary - if message&.event_summary.present? - Event.where(summary: message.event_summary).destroy_all - end + def watch_card_by_creator + card.watch_by creator + end + def track_commented_card + card.track_event :commented, comment_id: id + end + + # FIXME: This isn't right. We need to introduce an eventable polymorphic association for this. + def cleanup_events # Delete events that reference directly in particulars Event.where(particulars: { comment_id: id }).destroy_all end - - def card_comments_prior - card_comments.where(created_at: ...created_at) - end - - def card_comments - Comment.joins(:message).where(messages: { card: card }) - end end diff --git a/app/models/current.rb b/app/models/current.rb index e5546b93b..a4d0f0864 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -2,5 +2,4 @@ class Current < ActiveSupport::CurrentAttributes attribute :session delegate :user, to: :session, allow_nil: true - delegate :account, to: :user, allow_nil: true end diff --git a/app/models/event.rb b/app/models/event.rb index e64a8f896..ad17a5e8c 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -5,21 +5,13 @@ class Event < ApplicationRecord belongs_to :summary, touch: true, class_name: "EventSummary" belongs_to :card - has_one :account, through: :creator has_one :message, through: :summary has_one :comment, through: :message, source: :messageable, source_type: "Comment" scope :chronologically, -> { order created_at: :asc, id: :desc } - scope :non_boosts, -> { where.not action: :boosted } - scope :boosts, -> { where action: :boosted } - scope :comments, -> { where action: :commented } after_create -> { card.touch_last_active_at } - def boosted? - action == "boosted" - end - def commented? action == "commented" end diff --git a/app/models/event/particulars.rb b/app/models/event/particulars.rb index a9cec0452..389eda8ea 100644 --- a/app/models/event/particulars.rb +++ b/app/models/event/particulars.rb @@ -6,10 +6,10 @@ module Event::Particulars end def assignees - @assignees ||= account.users.where id: assignee_ids + @assignees ||= User.where id: assignee_ids end def comment - @comment ||= account.comments.find_by(id: comment_id) + @comment ||= Comment.find_by id: comment_id end end diff --git a/app/models/event_summary.rb b/app/models/event_summary.rb index b74a5a10c..fcfaabd83 100644 --- a/app/models/event_summary.rb +++ b/app/models/event_summary.rb @@ -5,16 +5,12 @@ class EventSummary < ApplicationRecord # FIXME: Consider persisting the body and compute at write time. def body - "#{main_summary} #{boosts_summary}".squish + events.map { |event| summarize(event) }.join(" ") end private delegate :time_ago_in_words, to: "ApplicationController.helpers" - def main_summary - events.non_boosts.map { |event| summarize(event) }.join(" ") - end - def summarize(event) case event.action when "published" @@ -39,12 +35,4 @@ class EventSummary < ApplicationRecord "#{event.creator.name} changed title from '#{event.particulars.dig('particulars', 'old_title')}' to '#{event.particulars.dig('particulars', 'new_title')}'." end end - - def boosts_summary - if tally = events.boosts.group(:creator).count.presence - tally.map do |creator, count| - "#{creator.name} +#{count}" - end.to_sentence + "." - end - end end diff --git a/app/models/filter/fields.rb b/app/models/filter/fields.rb index e6028e551..9ff9764d4 100644 --- a/app/models/filter/fields.rb +++ b/app/models/filter/fields.rb @@ -1,7 +1,7 @@ module Filter::Fields extend ActiveSupport::Concern - INDEXES = %w[ most_discussed most_boosted newest oldest latest stalled ] + INDEXES = %w[ newest oldest latest stalled ] delegate :default_value?, to: :class diff --git a/app/models/first_run.rb b/app/models/first_run.rb index 4115b8715..cc48de7ad 100644 --- a/app/models/first_run.rb +++ b/app/models/first_run.rb @@ -1,6 +1,7 @@ class FirstRun def self.create!(user_attributes) - account = Account.create!(name: "Fizzy") - account.users.member.create!(user_attributes) + Account.create!(name: "Fizzy") + Closure::Reason.create_defaults + User.member.create!(user_attributes) end end diff --git a/app/models/message.rb b/app/models/message.rb index bb5dea5a9..7d950b3b7 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -4,16 +4,4 @@ class Message < ApplicationRecord delegated_type :messageable, types: Messageable::TYPES, inverse_of: :message, dependent: :destroy scope :chronologically, -> { order created_at: :asc, id: :desc } - - after_create :created - after_destroy :destroyed - - private - def created - card.comment_created(comment) if comment? - end - - def destroyed - card.comment_destroyed if comment? - end end diff --git a/app/models/reaction.rb b/app/models/reaction.rb index 6eefb7963..45d9c1796 100644 --- a/app/models/reaction.rb +++ b/app/models/reaction.rb @@ -4,8 +4,6 @@ class Reaction < ApplicationRecord scope :ordered, -> { order(:created_at) } - validates_presence_of :content - def all_emoji? content.match? /\A(\p{Emoji_Presentation}|\p{Extended_Pictographic}|\uFE0F)+\z/u end diff --git a/app/models/tag.rb b/app/models/tag.rb index 128a9aaac..eadaa72f9 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,8 +1,6 @@ class Tag < ApplicationRecord include Filterable - belongs_to :account, default: -> { Current.account }, touch: true - has_many :taggings, dependent: :destroy has_many :cards, through: :taggings diff --git a/app/models/user.rb b/app/models/user.rb index f1b6a0d1f..a22841c42 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,8 +1,6 @@ class User < ApplicationRecord include Accessor, Assignee, Avatar, Role, Transferable - belongs_to :account - has_many :sessions, dependent: :destroy has_secure_password validations: false diff --git a/app/models/user/accessor.rb b/app/models/user/accessor.rb index f6c902c50..89534b777 100644 --- a/app/models/user/accessor.rb +++ b/app/models/user/accessor.rb @@ -11,6 +11,6 @@ module User::Accessor private def grant_access_to_collections - Access.insert_all account.collections.all_access.pluck(:id).collect { |collection_id| { collection_id: collection_id, user_id: id } } + Access.insert_all Collection.all_access.pluck(:id).collect { |collection_id| { collection_id: collection_id, user_id: id } } end end diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 625361037..1b5648679 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -10,10 +10,8 @@ module User::Role end class_methods do - def find_or_create_system_user(account) - account.users.find_or_create_by!(role: :system) do |user| - user.name = "System" - end + def system + find_or_create_by!(role: :system) { it.name = "System" } end end diff --git a/app/models/workflow.rb b/app/models/workflow.rb index 164d3eb47..df896cf09 100644 --- a/app/models/workflow.rb +++ b/app/models/workflow.rb @@ -1,4 +1,3 @@ class Workflow < ApplicationRecord - belongs_to :account has_many :stages, dependent: :delete_all end diff --git a/app/views/cards/_closure_toggle.html.erb b/app/views/cards/_closure_toggle.html.erb index 5cd93b41c..76edfa091 100644 --- a/app/views/cards/_closure_toggle.html.erb +++ b/app/views/cards/_closure_toggle.html.erb @@ -11,7 +11,7 @@ <%= icon_tag "caret-down" %>
<% if card.published? %> <%= turbo_frame_tag card, :edit do %> - <%= link_to card_title(card), edit_collection_card_path(card.collection, card), class: "card__title-link overflow-line-clamp" %> + <%= link_to card.title, edit_collection_card_path(card.collection, card), class: "card__title-link overflow-line-clamp" %> <% end %> <% else %> <%= form_with model: card, url: collection_card_path(card.collection, card), id: "card_form", data: { controller: "auto-save" } do |form| %> diff --git a/app/views/cards/display/_preview.html.erb b/app/views/cards/display/_preview.html.erb index f6582d6e0..7d673308c 100644 --- a/app/views/cards/display/_preview.html.erb +++ b/app/views/cards/display/_preview.html.erb @@ -7,11 +7,11 @@
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb
index 0907353a1..8bcd35e80 100644
--- a/app/views/events/index.html.erb
+++ b/app/views/events/index.html.erb
@@ -5,11 +5,11 @@
-
- <%= link_to account_users_path, class: "btn flex-item-justify-end" do %>
+ <%= link_to users_path, class: "btn flex-item-justify-end" do %>
<%= icon_tag "settings" %>
Account settings
<% end %>
diff --git a/app/views/filters/_assignees.html.erb b/app/views/filters/_assignees.html.erb
index 96aae698a..cb219d9c9 100644
--- a/app/views/filters/_assignees.html.erb
+++ b/app/views/filters/_assignees.html.erb
@@ -35,7 +35,7 @@
<%= icon_tag "check", class: "checked flex-item-justify-end" %>
- <%= card_title(card) %> + <%= card.title %>
<%= link_to collection_card_path(card.collection, card), class: "card__link" do %> - <%= card_title(card) %> + <%= card.title %> <% end %> <%= render "cards/stagings/stages", card: card if card.doing? %> diff --git a/app/views/cards/edit.html.erb b/app/views/cards/edit.html.erb index db9ae674d..5e5e0d1d9 100644 --- a/app/views/cards/edit.html.erb +++ b/app/views/cards/edit.html.erb @@ -2,10 +2,10 @@ <%= form_with model: @card, url: collection_card_path(@card.collection, @card), class: "flex flex-column gap full-width", data: { controller: "form" } do |form| %> <%= form.label :title, class: "flex flex-column align-center" do %> <%= form.text_area :title, class: "input input--textarea full-width borderless txt-align-start card__title-field", - required: true, autofocus: true, placeholder: "Name it…", - rows: 3, - data: { action: "keydown.enter->form#submit:prevent keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel focus->form#select" }, - style: "color: var(--spat-color); --input-border-radius: 0" %> + required: true, autofocus: true, placeholder: "Name it…", + rows: 3, + data: { action: "keydown.enter->form#submit:prevent keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel focus->form#select" }, + style: "color: var(--spat-color); --input-border-radius: 0" %> <% end %> <%= form.button "Save", type: :submit, hidden: true %> <%= link_to "Close editor and discard changes", collection_card_path(@card.collection, @card), data: { form_target: "cancel" }, hidden: true %> diff --git a/app/views/messages/_message.html.erb b/app/views/cards/messages/_message.html.erb similarity index 100% rename from app/views/messages/_message.html.erb rename to app/views/cards/messages/_message.html.erb diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index f28f3b135..f0151c3ce 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -1,4 +1,5 @@ -<% @page_title = card_title(@card) %> +<% @page_title = @card.title %> +<%= turbo_stream_from @card %> <% content_for :header do %> <% if @card.creating? && @card.can_recover_abandoned_creation? %> diff --git a/app/views/collections/edit.html.erb b/app/views/collections/edit.html.erb index 61fe4ca81..a31b65d2b 100644 --- a/app/views/collections/edit.html.erb +++ b/app/views/collections/edit.html.erb @@ -75,7 +75,7 @@ Choose a workflowUse a workflow to track progress in this collection.
<%= form_with model: @collection, url: collection_workflow_path(@collection), local: true, method: :patch, data: { controller: "form" } do |form| %> - <%= form.select :workflow_id, Current.account.workflows.map { |w| [w.name, w.id] }, { include_blank: "Choose…" }, class: "input input--select full-width", data: { action: "change->form#submit" } %> + <%= form.select :workflow_id, Workflow.all.map { |w| [w.name, w.id] }, { include_blank: "Choose…" }, class: "input input--select full-width", data: { action: "change->form#submit" } %> <% end %><%= link_to "Manage workflows", workflows_path, class: "btn btn--plain txt-link" %>
<%= Current.account.name %> / Latest activity
+<%= Account.sole.name %> / Latest activity
<%= render "events/filter" %>