Hotwired wi[

This commit is contained in:
2021-09-22 16:40:20 +02:00
parent a0c72b0caf
commit 9a318249dc
21 changed files with 381 additions and 6 deletions

View File

@@ -0,0 +1,20 @@
class HelloController < ApplicationController
before_action only: [:show, :edit, :update, :destroy]
def index
@employers = Employer.all
@employer = Employer.new
end
# def create
# @product.increment! :retweets_count
# redirect_to @tweet
# end
private
# def set_tweet
# # @tweet = Tweet.find(params[:tweet_id])
# end
end

View File

@@ -0,0 +1,10 @@
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.warnings = true
application.debug = false
window.Stimulus = application
export { application }

View File

@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}

View File

@@ -0,0 +1,7 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller
import { application } from "./application"
import HelloController from "./hello_controller"
application.register("hello", HelloController)

View File

@@ -5,9 +5,13 @@
//
import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import { Turbo } from "@hotwired/turbo-rails"
import * as ActiveStorage from "@rails/activestorage"
import "controllers"
import "channels"
Rails.start()
Turbolinks.start()
window.Turbo = Turbo
Turbo.start()
ActiveStorage.start()

View File

@@ -1,4 +1,8 @@
class Employer < ApplicationRecord
after_create_commit { broadcast_prepend_to "employers" }
after_update_commit { broadcast_replace_to "employers" }
after_destroy_commit { broadcast_remove_to "employers" }
include Recentable
has_many :subscriptions

View File

@@ -0,0 +1,7 @@
<%= turbo_frame_tag dom_id(employer) do %>
<div class="card card-body">
<div>Something </div>
<div><%= employer.name %></div>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
json.extract! employer, :id, :name

View File

@@ -0,0 +1,5 @@
<%= turbo_frame_tag dom_id(employer) do %>
<div class="card card-body">
<div><%= @employer.name %></div>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
json.extract! employer, :id, :name

View File

@@ -0,0 +1,23 @@
<%= form_with(model: employer, id: dom_id(employer)) do |form| %>
<% if employer.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(employer.errors.count, "error") %> prohibited this employer from being saved:</h2>
<ul>
<% tweet.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= form.label :name %>
<%= form.text_area :name %>
</div>
<div class="actions">
<%= form.submit %>
</div>
<% end %>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
json.array! @employers, partial: "tweets/tweet", as: :employer

View File

@@ -2,7 +2,7 @@
<%= bootstrap_form_with model: model, local: true do |form| %>
V <%= form.text_field :name %>
<%= form.text_field :name %>
<%= form.time_zone_select(:shoot_location_time_zone, nil, label: "Time zone of shoot location") %> <div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [project, :broadcasts], class: "col-3 text-reset" %>
<div class="col-9">