tybo 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9897851e74a06c11d9a138fd37ce454356f3d7d9df8735e481fafa40a45ecde1
4
- data.tar.gz: fbd99b2a4e4ffae5ee374e8a2bf69623ca80dcc20512e717d8cfb68d360f4710
3
+ metadata.gz: f587762e6fc941a150f59aa336d987faeee5d66a180f0bfc6f8e7868e92ba9ba
4
+ data.tar.gz: 32194ed86ca66273c8d601466028bde6b1e1189e9aa05ac30044703d22d0aab2
5
5
  SHA512:
6
- metadata.gz: 2c029d94231d4e20fe1b5498e3aac4f9f16c3d4c70b16316c0de63e55f3be79767e3ca174e1e90563d98b61d96ba505809440d95ca6bbda23cb69c4b68b63214
7
- data.tar.gz: dcec0696f8fa822cc8898e761836eda344d030f1156eb31034f88d2127b6edd679516bb663302075575d0939acef606eda66b92d2f1b2997dec8b02d69a60c94
6
+ metadata.gz: 2951055222ca10e692ed8e47e445dd1497967af74887e9c454ce1197fe1b883761586e95ba7840d9513062369df86cd67331a89393ec1c5f21ee03762af3c9b2
7
+ data.tar.gz: a50d6d4eef0e0586632ab8bf0da40d06b1d757cce5740a9361e02a2ee6f541b61a78d988c478f91206c90ddfc8160e50e0abda3670bd0b920a1b9d1cc230297d
@@ -29,7 +29,7 @@
29
29
  </div>
30
30
  <% end %>
31
31
 
32
- <div class="px-4 py-5 bg-white space-y-6 sm:p-6 shadow sm:rounded-md sm:overflow-hidden">
32
+ <div class="px-4 py-5 bg-white space-y-6 sm:p-6 shadow sm:rounded-md">
33
33
  <%= content %>
34
34
  </div>
35
35
  </div>
@@ -1,5 +1,5 @@
1
1
  <div class="my-5">
2
- <h3 class="text-lg leading-6 font-medium text-gray-900">
2
+ <h3 class="text-lg leading-6 bgfont-medium text-gray-900">
3
3
  <%= @subtitle %>
4
4
  </h3>
5
5
  </div>
@@ -1,3 +1,3 @@
1
1
  <div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
2
- <%= link_to '+', @path, class: "inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto" %>
3
- </div>
2
+ <%= link_to '+', @path, class: "inline-flex items-center justify-center rounded-md border border-transparent bg-custom px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-custom-700 focus:outline-none focus:ring-2 focus:ring-custom-500 focus:ring-offset-2 sm:w-auto" %>
3
+ </div>
@@ -1,8 +1,8 @@
1
1
  <div class=" md:flex md:w-64 md:flex-col md:fixed md:inset-y-0">
2
- <div class="flex-1 flex flex-col min-h-0 bg-sidebar">
2
+ <div class="flex-1 flex flex-col min-h-0 bg-custom">
3
3
  <div class="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
4
4
  <div class="flex items-center flex-shrink-0 px-4">
5
- <%= image_tag("https://tymate.com/assets/logos/logo-full-tymate-white-44c399f36de12ec8b69a86ec02ab13fc5c80842dd2333117658ead762ff15f93.svg", alt: "logo rif", class: 'mx-auto h-15 w-auto') %>
5
+ <%= image_tag("https://www.datocms-assets.com/33962/1667496758-logo-white.svg", alt: "logo rif", class: 'mx-auto h-15 w-auto') %>
6
6
  </div>
7
7
 
8
8
  <nav class="mt-5 flex-1 px-2 space-y-1" aria-label="Sidebar">
@@ -0,0 +1,3 @@
1
+ <th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900 hover:cursor-pointer">
2
+ <%= sort_link(@q, @column_name, @label, default_order: :asc) %>
3
+ </th>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class ActiveRecordThComponent < ViewComponent::Base
5
+ include Ransack::Helpers::FormHelper
6
+
7
+ def initialize(column_name:, ransack_object: )
8
+ @column_name = column_name
9
+ @q = ransack_object
10
+ @label = label
11
+ end
12
+
13
+ def label
14
+ I18n.t("bo.#{@q.object.klass.to_s.underscore}.attributes.#{@column_name}")
15
+ end
16
+ end
17
+ end
@@ -3,5 +3,8 @@
3
3
  <% ths.each do |th| %>
4
4
  <%= th %>
5
5
  <% end %>
6
+ <% active_record_ths.each do |th| %>
7
+ <%= th %>
8
+ <% end %>
6
9
  </tr>
7
10
  </thead>
@@ -3,5 +3,6 @@
3
3
  module Tables
4
4
  class TheadComponent < ViewComponent::Base
5
5
  renders_many :ths, Tables::ThComponent
6
+ renders_many :active_record_ths, Tables::ActiveRecordThComponent
6
7
  end
7
8
  end
@@ -0,0 +1,14 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import { FetchRequest, patch } from '@rails/request.js'
3
+
4
+ export default class extends Controller {
5
+ static values = { url: String, method: String, attachmentId: Number }
6
+
7
+ async toggle(event) {
8
+ event.preventDefault()
9
+
10
+ const request = new FetchRequest(this.methodValue, this.urlValue, {responseKind: "turbo-stream", body: { attachment_id: this.attachmentIdValue}})
11
+ const response = await request.perform()
12
+ if (response.ok) {}
13
+ }
14
+ }
@@ -0,0 +1,15 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ["menu"]
5
+
6
+ toggle() {
7
+ this.menuTarget.classList.toggle("hidden")
8
+ }
9
+
10
+ hide(event) {
11
+ if (!this.element.contains(event.target) && !this.menuTarget.classList.contains('hidden')) {
12
+ this.menuTarget.classList.add("hidden")
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ export { default as Attachments } from "./attachments_controller";
2
+ export { default as Dropdown } from "./dropdown_controller";
3
+ export { default as Flash } from "./flash_controller";
4
+ export { default as SearchForm } from "./search_form_controller";
5
+ export { default as TsSearch } from "./ts/search_controller";
6
+ export { default as TsSelect } from "./ts/select_controller";
@@ -0,0 +1,61 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ['questionKind', 'questionType', 'newQuestion', 'choices', 'documentType']
5
+
6
+ changeType(e) {
7
+ let questionType = e.target.selectedOptions[0].value
8
+ let kindInput = this.questionKindTarget
9
+ this.getKindInput(questionType, kindInput)
10
+ }
11
+
12
+
13
+ getKindInput(questionType, kindInput) {
14
+ fetch(`/admin/questions/kinds?type=${questionType}`, {
15
+ method: 'GET',
16
+ }).then(response => response.json())
17
+ .then(data => {
18
+ kindInput.options.length = 0 // reset options in select
19
+ data.unshift('')
20
+ for (let i in data) { // feed options in select with data array
21
+ kindInput.options[kindInput.options.length] = new Option(data[i][0], data[i][1]);
22
+ }
23
+ this.displayChoiceBtn()
24
+ })
25
+ }
26
+ changeKind() {
27
+ this.displayChoiceBtn()
28
+ this.removeChoices()
29
+ }
30
+
31
+ removeChoices() {
32
+ document.getElementById('choices').innerHTML = ''
33
+ }
34
+
35
+ updateChoicePartial() {
36
+ let questionKind = this.questionKindTarget.selectedOptions[0].value
37
+ let questionType = this.questionTypeTarget.selectedOptions[0].value
38
+ let choices = this.choicesTarget
39
+ fetch(`/admin/questions/update_nested_form?type=${questionType}&kind=${questionKind}`, {
40
+ method: 'GET',
41
+ }).then(response => response.json())
42
+ .then(data => {
43
+ choices.innerHTML = data
44
+ })
45
+ }
46
+ displayChoiceBtn() {
47
+ let questionKind = this.questionKindTarget.selectedOptions[0].value
48
+ let questionType = this.questionTypeTarget.selectedOptions[0].value
49
+ let btn = document.getElementById('add-choice')
50
+ if (Boolean(questionKind) && Boolean(questionType) && questionType != "Questions::Input") {
51
+ btn.classList.remove('hidden')
52
+ } else {
53
+ btn.classList.add('hidden')
54
+ }
55
+ }
56
+
57
+ addQuestion() {
58
+ this.newQuestionTargets[0].classList.remove('hidden')
59
+ location.hash = "#" + 'newQuestion';
60
+ }
61
+ }
@@ -0,0 +1,20 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ["form"]
5
+
6
+ search() {
7
+ clearTimeout(this.timeout)
8
+ this.timeout = setTimeout(() => {
9
+ this.formTarget.requestSubmit()
10
+ }, 200)
11
+ }
12
+
13
+ setBooleanField(e) {
14
+ let value = e.target.getAttribute('data-value')
15
+ let targetId = e.target.getAttribute('data-target-id')
16
+ let target = document.getElementById(targetId)
17
+ target.value = value
18
+ this.formTarget.requestSubmit()
19
+ }
20
+ }
@@ -0,0 +1,35 @@
1
+ // app/javascript/controllers/ts/search_controller.js
2
+
3
+ import { Controller } from "@hotwired/stimulus"
4
+ import { get } from '@rails/request.js'
5
+ import TomSelect from "tom-select"
6
+
7
+ // Connects to data-controller="ts--search"
8
+ export default class extends Controller {
9
+ static values = { url: String }
10
+
11
+ connect() {
12
+
13
+ var config = {
14
+ plugins: ['clear_button'],
15
+ valueField: 'value',
16
+ load: (q, callback) => this.search(q, callback)
17
+ }
18
+ new TomSelect(this.element, config)
19
+ }
20
+
21
+ async search(q, callback) {
22
+ const response = await get(this.urlValue, {
23
+ query: { q: q },
24
+ responseKind: 'json'
25
+ })
26
+
27
+ if (response.ok) {
28
+ const list = await response.json
29
+ callback(list)
30
+ } else {
31
+ callback()
32
+ }
33
+ }
34
+
35
+ }
@@ -0,0 +1,9 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import TomSelect from "tom-select"
3
+
4
+ // Connects to data-controller="ts--select"
5
+ export default class extends Controller {
6
+ connect() {
7
+ new TomSelect(this.element, { create: false, plugins: ['remove_button'] })
8
+ }
9
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tybo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Camblan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-06 00:00:00.000000000 Z
12
+ date: 2022-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turbo-rails
@@ -137,6 +137,8 @@ files:
137
137
  - lib/app/components/sidebar_item_component.rb
138
138
  - lib/app/components/sign_out_button_component.html.erb
139
139
  - lib/app/components/sign_out_button_component.rb
140
+ - lib/app/components/tables/active_record_th_component.html.erb
141
+ - lib/app/components/tables/active_record_th_component.rb
140
142
  - lib/app/components/tables/table_component.html.erb
141
143
  - lib/app/components/tables/table_component.rb
142
144
  - lib/app/components/tables/tbody_component.html.erb
@@ -151,7 +153,14 @@ files:
151
153
  - lib/app/components/tables/tr_component.rb
152
154
  - lib/app/helpers/application_helper.rb
153
155
  - lib/app/helpers/flash_helper.rb
156
+ - lib/app/javascript/controllers/attachments_controller.js
157
+ - lib/app/javascript/controllers/dropdown_controller.js
154
158
  - lib/app/javascript/controllers/flash_controller.js
159
+ - lib/app/javascript/controllers/index.js
160
+ - lib/app/javascript/controllers/questions_controller.js
161
+ - lib/app/javascript/controllers/search_form_controller.js
162
+ - lib/app/javascript/controllers/ts/search_controller.js
163
+ - lib/app/javascript/controllers/ts/select_controller.js
155
164
  - lib/tybo.rb
156
165
  homepage: https://rubygems.org/gems/backoffice-components
157
166
  licenses: