Add assignees to a bubble WIP
- Still needs UI to display multiple assignees - Still needs UI for changing/removing assignees
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17"><path d="m11.5 10.3-.6-.2c-.2-.5-.3-1.1-.1-1.6 1.1-1.2 1.6-2.7 1.5-4.3 0-2.4-1.6-4.2-3.8-4.2S4.7 1.8 4.7 4.2c-.1 1.5.4 3.1 1.5 4.3.2.5.2 1.1-.1 1.6l-.6.2c-2.4.9-4.2 1.5-4.8 2.6-.4 1.2-.7 2.4-.7 3.6 0 .3.2.5.5.5h16c.3 0 .5-.2.5-.5 0-1.2-.3-2.4-.7-3.5-.6-1.1-2.4-1.8-4.8-2.7"/></svg>
|
||||
|
After Width: | Height: | Size: 341 B |
@@ -134,6 +134,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
&.bubble__assignee {
|
||||
aspect-ratio: 1;
|
||||
inset: -1cqi auto auto 28cqi;
|
||||
padding: 0.4em;
|
||||
|
||||
select {
|
||||
inset: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.windshield .bubble:hover & {
|
||||
transform: translate(1rem, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.bubble__assignee--new {
|
||||
.windshield & {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.bubble__attachment {
|
||||
aspect-ratio: 1;
|
||||
inset: -4cqi 24cqi auto auto;
|
||||
@@ -199,7 +222,7 @@
|
||||
white-space: nowrap;
|
||||
z-index: 1;
|
||||
|
||||
&:has(.input:not([type="file"], [type="date"])) {
|
||||
&:has(.input:not([type="file"], [type="date"], select)) {
|
||||
border-radius: 2em;
|
||||
padding: 0.2em 0.5em;
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
class AssignmentsController < ApplicationController
|
||||
before_action :set_bubble, only: %i[ create update ]
|
||||
before_action :set_assignment, only: :update
|
||||
|
||||
def create
|
||||
@assignment = @bubble.assignments.build(assignment_params)
|
||||
@assignment.save
|
||||
|
||||
redirect_to @bubble
|
||||
end
|
||||
|
||||
def update
|
||||
@assignment.update(assignment_params)
|
||||
redirect_to @bubble
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assignment_params
|
||||
params.require(:assignment).permit(:user_id)
|
||||
end
|
||||
|
||||
def set_assignment
|
||||
@assignment = @bubble.assignments.find(params[:id])
|
||||
end
|
||||
|
||||
def set_bubble
|
||||
@bubble = Bubble.find(params[:bubble_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class Assignment < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :bubble
|
||||
|
||||
validates :user_id, uniqueness: { scope: :bubble_id }
|
||||
end
|
||||
@@ -7,6 +7,9 @@ class Bubble < ApplicationRecord
|
||||
has_many :taggings, dependent: :destroy
|
||||
has_many :tags, through: :taggings
|
||||
|
||||
has_many :assignments, dependent: :destroy
|
||||
has_many :assignees, through: :assignments, source: :user
|
||||
|
||||
has_one_attached :image, dependent: :purge_later
|
||||
|
||||
enum :color, %w[
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
class User < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
has_many :assignments
|
||||
has_many :assigned, through: :assignments, source: :bubble
|
||||
|
||||
has_many :sessions, dependent: :destroy
|
||||
has_secure_password validations: false
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<span class="bubble__bubble bubble__meta bubble__assignee <%= "bubble__assignee--new" if bubble.assignees.none? %>">
|
||||
<%= form_with model: [bubble, Assignment.new], data: { controller: "form" } do |form| %>
|
||||
<label class="btn btn--plain position-relative" style="--btn-icon-size: 2em;">
|
||||
<% if bubble.assignees.any? %>
|
||||
<figure class="avatar fill-black txt-reversed flex-item-no-shrink"><strong><%= bubble.assignees.first.initials %></strong></figure>
|
||||
<% else %>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17" fill="var(--bubble-color)"><path d="m11.5 10.3-.6-.2c-.2-.5-.3-1.1-.1-1.6 1.1-1.2 1.6-2.7 1.5-4.3 0-2.4-1.6-4.2-3.8-4.2S4.7 1.8 4.7 4.2c-.1 1.5.4 3.1 1.5 4.3.2.5.2 1.1-.1 1.6l-.6.2c-2.4.9-4.2 1.5-4.8 2.6-.4 1.2-.7 2.4-.7 3.6 0 .3.2.5.5.5h16c.3 0 .5-.2.5-.5 0-1.2-.3-2.4-.7-3.5-.6-1.1-2.4-1.8-4.8-2.7"/></svg>
|
||||
<% end %>
|
||||
<%= form.collection_select :user_id, User.all, :id, :name,
|
||||
{ prompt: "Assign to…", selected: bubble.assignees.pluck(:user_id) },
|
||||
{ class: "input input--hidden txt-medium", data: { action: "change->form#submit click->form#showPicker" } }
|
||||
%>
|
||||
<span class="for-screen-reader">Assign to…</span>
|
||||
</label>
|
||||
<%= form.submit "Save", class: "btn", hidden: true %>
|
||||
<% end %>
|
||||
</span>
|
||||
@@ -14,6 +14,7 @@
|
||||
<span class="for-screen-reader"><%= bubble.title %></span>
|
||||
<% end %>
|
||||
|
||||
<%= render "bubbles/assignments", bubble: bubble %>
|
||||
<%= render "bubbles/boosts", bubble: bubble %>
|
||||
<%= render "bubbles/color", bubble: bubble %>
|
||||
<%= render "bubbles/date", bubble: bubble %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= form_with model: bubble, data: { controller: "form" } do |form| %>
|
||||
<label class="bubble__bubble bubble__meta bubble__date">
|
||||
<%= bubble.due_on.strftime("%b <br> %d").html_safe %>
|
||||
<%= form.date_field :due_on, class: "input input--hidden", data: { action: "change->form#submit click->form#showPicker"} %>
|
||||
<%= form.date_field :due_on, class: "input input--hidden", data: { action: "change->form#submit click->form#showPicker" } %>
|
||||
<span class="for-screen-reader">Change the due date</span>
|
||||
</label>
|
||||
<% end %>
|
||||
|
||||
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
||||
resources :bubbles do
|
||||
resource :image, controller: "bubbles/images"
|
||||
|
||||
resources :assignments
|
||||
resources :boosts
|
||||
resources :comments
|
||||
resources :tags, shallow: true
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class CreateAssignments < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :assignments do |t|
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.references :bubble, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Generated
+12
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2024_09_13_172737) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2024_09_17_174301) do
|
||||
create_table "accounts", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -46,6 +46,15 @@ ActiveRecord::Schema[8.0].define(version: 2024_09_13_172737) do
|
||||
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
end
|
||||
|
||||
create_table "assignments", force: :cascade do |t|
|
||||
t.integer "user_id", null: false
|
||||
t.integer "bubble_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["bubble_id"], name: "index_assignments_on_bubble_id"
|
||||
t.index ["user_id"], name: "index_assignments_on_user_id"
|
||||
end
|
||||
|
||||
create_table "boosts", force: :cascade do |t|
|
||||
t.string "body"
|
||||
t.integer "creator_id", null: false
|
||||
@@ -111,6 +120,8 @@ ActiveRecord::Schema[8.0].define(version: 2024_09_13_172737) do
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "assignments", "bubbles"
|
||||
add_foreign_key "assignments", "users"
|
||||
add_foreign_key "sessions", "users"
|
||||
add_foreign_key "taggings", "bubbles"
|
||||
add_foreign_key "taggings", "tags"
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
user: :kevin
|
||||
bubble: one
|
||||
|
||||
two:
|
||||
user: :jz
|
||||
bubble: two
|
||||
Vendored
+3
-2
@@ -3,13 +3,14 @@
|
||||
one:
|
||||
title: The logo isn't big enough
|
||||
body: Make the logo bigger.
|
||||
color: '#AF2E1B'
|
||||
color: '#ED8008'
|
||||
creator: :david
|
||||
due_on: <%= 3.days.from_now %>
|
||||
|
||||
two:
|
||||
title: Layout is broken
|
||||
body: The page scrolls horizontally on mobile devices.
|
||||
color: '#CC6324'
|
||||
color: '#698F9C'
|
||||
creator: :jz
|
||||
|
||||
three:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class AssignmentTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user