b4um_generators 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c28062a0ee906885d252d4f10519103efd322fb0b4543f4e2c50583e806cb8eb
4
- data.tar.gz: 914c0f060ab2e9f27ab11441f66c822696c7d2c928038880fb2c31f2c6113546
3
+ metadata.gz: 32be49cb4a38e8c75eba464939aa99d73d45784f0434d3aa75f0b4d7fd57862f
4
+ data.tar.gz: a3af1d5dcb53dd3aa945f92f05ec84bdb271c0a6ffc14fb1c99c96232d7a6407
5
5
  SHA512:
6
- metadata.gz: 8f0e80c477c65da9362ea6bff1c23760d620a639e40cda8ab3070ff2e6389dd70cb305bce39ea837259a1ed5d5ca33273217f87f8037d607d3774b9d60ffa155
7
- data.tar.gz: b94e7e85275276d551a090797bf08bccaabfe90e89ab9ed10d9b2208a1e092605eb563411fd79700b8a0e5bbf1e4042d093c3688cd9d160733daa5cf54a0b5e2
6
+ metadata.gz: c00cf8cab52aa8f5edf31b01ac68e948c2f8019ba2978542546be8daa79a138c40673b421c82ba5933e51553b781fbd700fcac3857d973b3da13816904e20b90
7
+ data.tar.gz: d9b452a787712782c27a4a02799cac27b0ee2566bb97bb8e14875fe521e89a17eb2632873a5c772385e78264abf0204a3dba696b37c830e20d911c01ae17b220
data/CHANGELOG.md CHANGED
@@ -4,6 +4,33 @@ All notable changes to b4um Generators will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.0] - 2026-10-14
8
+
9
+ ### Added
10
+
11
+ - Added complete Todo application generator with `b4um:todo`
12
+ - Added task creation, completion, reopening and deletion
13
+ - Added separate lists for open and completed tasks
14
+ - Added automatic task counters and progress tracking
15
+ - Added progress bar with completion percentage
16
+ - Added Turbo Stream updates without full page reloads
17
+ - Added Stimulus controller for task input handling
18
+ - Added automatic input reset after successful task creation
19
+ - Added responsive Todo layout with b4um cards and floating labels
20
+ - Added light and dark mode support for Todo components
21
+ - Added optional `--owner=MODEL` support for personal Todo lists
22
+ - Added integration with b4um authentication and current account helpers
23
+ - Added owner-specific task access protection
24
+ - Added HTTP 401 responses for unauthenticated owner-specific Todo requests
25
+ - Added 35 RSpec examples for the Todo generator
26
+
27
+ ### Changed
28
+
29
+ - Extended `b4um:help` with Todo generator documentation
30
+ - Extended Help generator RSpec coverage for Todo
31
+ - Updated English and German README documentation
32
+ - Updated the generator overview to include `b4um:todo`
33
+
7
34
  ## [0.4.2] - 2026-10-13
8
35
 
9
36
  ### Fixed
data/README.de.md CHANGED
@@ -6,8 +6,8 @@ b4um Generators ist eine Sammlung wiederverwendbarer Rails-Generatoren, Template
6
6
  für b4um-Rails-Projekte.
7
7
 
8
8
  Das Gem bietet eine einheitliche Grundlage für Rails-Anwendungen und enthält Generatoren für Scaffolds, Controller,
9
- Bento-Layouts, Tabellen, Pagination, Infinite Scroll, Suche, Kommentare, Authentifizierung, Administration, Gastzugänge,
10
- Attachments und Rich-Text-Bearbeitung.
9
+ Bento-Layouts, Tabellen, Pagination, Infinite Scroll, Suche, Sortierung, Todo-Listen, Kommentare, Authentifizierung,
10
+ Administration, Gastzugänge, Attachments und Rich-Text-Bearbeitung.
11
11
 
12
12
  Die generierten Komponenten verwenden ein gemeinsames b4um-Styling und sind darauf ausgelegt, miteinander zu
13
13
  funktionieren.
@@ -24,7 +24,7 @@ b4um Generators wird während der Entwicklung derzeit als lokales Gem verwendet.
24
24
  Füge das Gem zur `Gemfile` der Rails-Anwendung hinzu:
25
25
 
26
26
  ```ruby
27
- gem "b4um_generators", "~> 0.4.2", path: "/pfad/zu/b4um_generators"
27
+ gem "b4um_generators", "~> 0.5.0", path: "/pfad/zu/b4um_generators"
28
28
  ```
29
29
 
30
30
  Führe anschließend aus:
@@ -82,6 +82,7 @@ b4um:pagination
82
82
  b4um:infinite_scroll
83
83
  b4um:search
84
84
  b4um:sortable
85
+ b4um:todo
85
86
  b4um:comments
86
87
  b4um:in_place
87
88
  b4um:authentication
@@ -1146,6 +1147,119 @@ Dadurch entstehen entsprechend `/produktuebersicht`, `/verwaltung` und `/admin`.
1146
1147
  Eine separate Sortierseite ermöglicht außerdem, nur die `sort`-Action durch die Authentifizierung zu schützen, während
1147
1148
  der normale Ressourcen-Index öffentlich bleiben kann.
1148
1149
 
1150
+ ## Todo
1151
+
1152
+ Erzeuge eine vollständige Todo-Anwendung mit Turbo Streams, Stimulus und dem einheitlichen b4um-Styling:
1153
+
1154
+ ```bash
1155
+ bin/rails generate b4um:todo Task
1156
+ bin/rails db:migrate
1157
+ ```
1158
+
1159
+ Der Generator erstellt eine sofort verwendbare Aufgabenliste, ohne dass ein zusätzliches Todo-Gem erforderlich ist.
1160
+
1161
+ Standardmäßig werden Aufgaben gemeinsam innerhalb der Anwendung verwaltet und sind keinem einzelnen Benutzer zugeordnet.
1162
+
1163
+ Die generierte Todo-Anwendung ist erreichbar unter:
1164
+
1165
+ ```text
1166
+ /tasks
1167
+ ```
1168
+
1169
+ ### Funktionen
1170
+
1171
+ Der Todo-Generator bietet:
1172
+
1173
+ - Neue Aufgaben erstellen
1174
+ - Aufgaben als erledigt markieren
1175
+ - Erledigte Aufgaben wieder öffnen
1176
+ - Aufgaben löschen
1177
+ - Getrennte Listen für offene und erledigte Aufgaben
1178
+ - Automatische Aufgabenzähler
1179
+ - Fortschrittsbalken mit prozentualer Anzeige
1180
+ - Aktualisierungen mit Turbo Streams ohne vollständiges Neuladen der Seite
1181
+ - Stimulus-Controller für die Aufgabeneingabe
1182
+ - Automatisches Zurücksetzen des Eingabefeldes nach erfolgreicher Erstellung
1183
+ - b4um Floating Labels
1184
+ - Responsives b4um-Kartenlayout
1185
+ - Unterstützung für Light Mode und Dark Mode
1186
+ - Optionale Zuordnung zu einem Benutzerkonto
1187
+ - Zugriffsschutz für benutzerspezifische Aufgaben
1188
+
1189
+ ### Persönliche Todo-Listen
1190
+
1191
+ Todo-Listen können optional einem Authentifizierungsmodell zugeordnet werden.
1192
+
1193
+ Mit `--owner` werden Aufgaben einzelnen Benutzern zugewiesen:
1194
+
1195
+ ```bash
1196
+ bin/rails generate b4um:todo Task --owner=User
1197
+ bin/rails db:migrate
1198
+ ```
1199
+
1200
+ Das angegebene Benutzer- beziehungsweise Eigentümermodell muss bereits existieren.
1201
+
1202
+ Wird ein Eigentümermodell angegeben, erhält jedes angemeldete Benutzerkonto seine eigene Todo-Liste.
1203
+
1204
+ Die Aufgaben werden über die Verknüpfung des aktuell angemeldeten Kontos geladen. Dadurch können Benutzer nicht auf
1205
+ Aufgaben anderer Konten zugreifen.
1206
+
1207
+ Nicht authentifizierte Anfragen an benutzerspezifische Todo-Aktionen erhalten den HTTP-Status `401 Unauthorized`.
1208
+
1209
+ ### Integration mit der Authentifizierung
1210
+
1211
+ Der Todo-Generator arbeitet mit dem bestehenden b4um-Authentifizierungssystem zusammen.
1212
+
1213
+ Ein vollständiges Beispiel:
1214
+
1215
+ ```bash
1216
+ bin/rails generate b4um:scaffold User name:string email:string password_digest:string
1217
+ bin/rails db:migrate
1218
+
1219
+ bin/rails generate b4um:authentication User
1220
+
1221
+ bin/rails generate b4um:todo Task --owner=User
1222
+ bin/rails db:migrate
1223
+ ```
1224
+
1225
+ Die Passwort-Authentifizierung benötigt bcrypt. Dieses kann über `b4um:install` installiert werden.
1226
+
1227
+ Die Option `--owner` unterstützt auch andere Authentifizierungsmodelle:
1228
+
1229
+ ```bash
1230
+ bin/rails generate b4um:todo Task --owner=Member
1231
+ bin/rails generate b4um:todo Task --owner=Customer
1232
+ ```
1233
+
1234
+ Der generierte Controller verwendet automatisch den zum Modell passenden Helper für das aktuell angemeldete Konto:
1235
+
1236
+ ```ruby
1237
+ current_user
1238
+ current_member
1239
+ current_customer
1240
+ ```
1241
+
1242
+ ### Generierte Dateien
1243
+
1244
+ Für das standardmäßige `Task`-Modell erstellt der Generator folgende Komponenten:
1245
+
1246
+ - Task-Modell und Datenbankmigration
1247
+ - Tasks-Controller
1248
+ - Ressourcen-Routen
1249
+ - Todo-Index-View
1250
+ - Task-Partial
1251
+ - Fortschritts-Partial
1252
+ - Todo-Stylesheet
1253
+ - Stimulus-Controller
1254
+
1255
+ Nach dem Generieren muss die Datenbankmigration ausgeführt werden:
1256
+
1257
+ ```bash
1258
+ bin/rails db:migrate
1259
+ ```
1260
+
1261
+ Anschließend kann die Todo-Anwendung verwendet werden.
1262
+
1149
1263
  ## Kommentare
1150
1264
 
1151
1265
  Füge einem bestehenden Modell polymorphe Kommentare hinzu:
@@ -1549,7 +1663,7 @@ wird.
1549
1663
 
1550
1664
  ## Version
1551
1665
 
1552
- Aktuelle Version: `0.4.2`
1666
+ Aktuelle Version: `0.5.0`
1553
1667
 
1554
1668
  ## Autor
1555
1669
 
data/README.md CHANGED
@@ -6,8 +6,8 @@ b4um Generators is a collection of reusable Rails generators, templates, compone
6
6
  Rails projects.
7
7
 
8
8
  The gem provides a consistent starting point for Rails applications and includes generators for scaffolds, controllers,
9
- Bento layouts, tables, pagination, infinite scrolling, search, sorting, comments, authentication, administrator
10
- management, guest access, attachments and rich-text editing.
9
+ Bento layouts, tables, pagination, infinite scrolling, search, sorting, Todo lists, comments, authentication,
10
+ administrator management, guest access, attachments and rich-text editing.
11
11
 
12
12
  Generated components share the same b4um styling and are designed to work together.
13
13
 
@@ -23,7 +23,7 @@ b4um Generators is currently used as a local gem during development.
23
23
  Add the gem to the Rails application's `Gemfile`:
24
24
 
25
25
  ```ruby
26
- gem "b4um_generators", "~> 0.4.2", path: "/path/to/b4um_generators"
26
+ gem "b4um_generators", "~> 0.5.0", path: "/path/to/b4um_generators"
27
27
  ```
28
28
 
29
29
  Then run:
@@ -80,6 +80,7 @@ b4um:pagination
80
80
  b4um:infinite_scroll
81
81
  b4um:search
82
82
  b4um:sortable
83
+ b4um:todo
83
84
  b4um:comments
84
85
  b4um:in_place
85
86
  b4um:authentication
@@ -1125,6 +1126,119 @@ These create `/produktuebersicht`, `/verwaltung`, and `/admin` respectively.
1125
1126
  Using a separate sortable page also makes it possible to protect only the `sort` action with authentication while
1126
1127
  keeping the regular resource index public.
1127
1128
 
1129
+ ## Todo
1130
+
1131
+ Generate a complete Todo application with Turbo Streams, Stimulus and b4um styling:
1132
+
1133
+ ```bash
1134
+ bin/rails generate b4um:todo Task
1135
+ bin/rails db:migrate
1136
+ ```
1137
+
1138
+ The generator creates a ready-to-use Todo list without requiring an additional Todo gem.
1139
+
1140
+ By default, tasks are shared across the application and are not assigned to individual users.
1141
+
1142
+ The generated Todo application is available at:
1143
+
1144
+ ```text
1145
+ /tasks
1146
+ ```
1147
+
1148
+ ### Features
1149
+
1150
+ The Todo generator provides:
1151
+
1152
+ - Create new tasks
1153
+ - Mark tasks as completed
1154
+ - Reopen completed tasks
1155
+ - Delete tasks
1156
+ - Separate lists for open and completed tasks
1157
+ - Automatic task counters
1158
+ - Progress bar with completion percentage
1159
+ - Turbo Stream updates without full page reloads
1160
+ - Stimulus controller for task input handling
1161
+ - Automatic input reset after successful creation
1162
+ - b4um floating labels
1163
+ - Responsive b4um card layout
1164
+ - Light and dark mode support
1165
+ - Optional owner association
1166
+ - Owner-specific task access protection
1167
+
1168
+ ### Personal Todo Lists
1169
+
1170
+ Todo lists can optionally be associated with an authentication model.
1171
+
1172
+ Use `--owner` to assign tasks to individual users:
1173
+
1174
+ ```bash
1175
+ bin/rails generate b4um:todo Task --owner=User
1176
+ bin/rails db:migrate
1177
+ ```
1178
+
1179
+ The owner model must already exist.
1180
+
1181
+ When an owner is configured, each authenticated account has its own Todo list.
1182
+
1183
+ Tasks are loaded through the current owner's association, preventing users from accessing tasks belonging to another
1184
+ account.
1185
+
1186
+ Unauthenticated requests to owner-specific Todo actions receive HTTP `401 Unauthorized`.
1187
+
1188
+ ### Authentication Integration
1189
+
1190
+ The Todo generator integrates with the existing b4um authentication system.
1191
+
1192
+ A complete example:
1193
+
1194
+ ```bash
1195
+ bin/rails generate b4um:scaffold User name:string email:string password_digest:string
1196
+ bin/rails db:migrate
1197
+
1198
+ bin/rails generate b4um:authentication User
1199
+
1200
+ bin/rails generate b4um:todo Task --owner=User
1201
+ bin/rails db:migrate
1202
+ ```
1203
+
1204
+ Password authentication requires bcrypt, which can be installed through `b4um:install`.
1205
+
1206
+ The owner option also supports other authentication models:
1207
+
1208
+ ```bash
1209
+ bin/rails generate b4um:todo Task --owner=Member
1210
+ bin/rails generate b4um:todo Task --owner=Customer
1211
+ ```
1212
+
1213
+ The generated controller uses the corresponding current account helper:
1214
+
1215
+ ```ruby
1216
+ current_user
1217
+ current_member
1218
+ current_customer
1219
+ ```
1220
+
1221
+ ### Generated Files
1222
+
1223
+ For the default `Task` model, the generator creates the following components:
1224
+
1225
+ - Task model and database migration
1226
+ - Tasks controller
1227
+ - Resource routes
1228
+ - Todo index view
1229
+ - Task partial
1230
+ - Progress partial
1231
+ - Todo stylesheet
1232
+ - Stimulus controller
1233
+
1234
+ After generation, run:
1235
+
1236
+ ```bash
1237
+ bin/rails db:migrate
1238
+ ```
1239
+
1240
+ The Todo application is then ready to use.
1241
+
1128
1242
  ## Comments
1129
1243
 
1130
1244
  Add polymorphic comments to an existing model:
@@ -1524,7 +1638,7 @@ The gem can be tested locally by referencing the repository with `path:` from a
1524
1638
 
1525
1639
  ## Version
1526
1640
 
1527
- Current version: `0.4.2`
1641
+ Current version: `0.5.0`
1528
1642
 
1529
1643
  ## Author
1530
1644
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module B4umGenerators
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -1172,6 +1172,95 @@ module B4um
1172
1172
  - Safe repeated generator runs
1173
1173
 
1174
1174
 
1175
+ TODO
1176
+
1177
+ bin/rails generate b4um:todo MODEL
1178
+
1179
+ Generates a complete Todo application for Rails.
1180
+
1181
+ Example:
1182
+
1183
+ bin/rails generate b4um:todo Task
1184
+ bin/rails db:migrate
1185
+
1186
+ By default, the Todo list is shared across the application.
1187
+ Tasks are not assigned to individual users.
1188
+
1189
+ To create personal Todo lists, use --owner:
1190
+
1191
+ bin/rails generate b4um:todo Task --owner=User
1192
+ bin/rails db:migrate
1193
+
1194
+ The owner model must already exist.
1195
+
1196
+ For user-specific Todo lists, b4um authentication can be
1197
+ installed first:
1198
+
1199
+ bin/rails generate b4um:scaffold User name:string email:string password_digest:string
1200
+ bin/rails db:migrate
1201
+ bin/rails generate b4um:authentication User
1202
+ bin/rails generate b4um:todo Task --owner=User
1203
+ bin/rails db:migrate
1204
+
1205
+ The owner option supports other authentication models:
1206
+
1207
+ --owner=User
1208
+ --owner=Member
1209
+ --owner=Customer
1210
+
1211
+ The generated controller uses the corresponding
1212
+ current owner helper, for example:
1213
+
1214
+ current_user
1215
+ current_member
1216
+ current_customer
1217
+
1218
+ With an owner, each account has its own Todo list.
1219
+
1220
+ Tasks are loaded through the current owner's association.
1221
+ Users cannot access tasks belonging to another account.
1222
+
1223
+ Unauthenticated requests to owner-specific Todo actions
1224
+ receive HTTP 401 Unauthorized.
1225
+
1226
+ Todo features:
1227
+
1228
+ - Create new tasks
1229
+ - Mark tasks as completed
1230
+ - Reopen completed tasks
1231
+ - Delete tasks
1232
+ - Separate lists for open and completed tasks
1233
+ - Automatic task counters
1234
+ - Progress bar with completion percentage
1235
+ - Turbo Stream updates without full page reloads
1236
+ - Stimulus controller for the task input
1237
+ - Automatic input reset after successful creation
1238
+ - b4um floating labels
1239
+ - Responsive b4um card layout
1240
+ - Light and dark mode support
1241
+ - Optional owner association with --owner
1242
+ - Owner-specific task access protection
1243
+
1244
+ The generator creates:
1245
+
1246
+ - Task model and database migration
1247
+ - Tasks controller
1248
+ - Resource routes
1249
+ - Index view
1250
+ - Task partial
1251
+ - Progress partial
1252
+ - Todo stylesheet
1253
+ - Stimulus controller
1254
+
1255
+ After generating the Todo application, run:
1256
+
1257
+ bin/rails db:migrate
1258
+
1259
+ With the default Task model, the Todo list is available at:
1260
+
1261
+ /tasks
1262
+
1263
+
1175
1264
  COMMENTS
1176
1265
 
1177
1266
  bin/rails generate b4um:comments MODEL
@@ -66,6 +66,21 @@
66
66
  --b4um-hero-teaser-background: rgba(255, 255, 255, 0.55);
67
67
  --b4um-hero-teaser-text: rgba(20, 20, 20, 0.9);
68
68
  --b4um-hero-teaser-border: rgba(255, 255, 255, 0.3);
69
+
70
+ /* todo */
71
+ --todo-primary: var(--b4um-primary);
72
+
73
+ --todo-primary-hover: var(--b4um-primary-hover);
74
+
75
+ --todo-background: #ffffff;
76
+ --todo-surface: #f7f9fb;
77
+ --todo-border: #e5e9ee;
78
+
79
+ --todo-text: #20252b;
80
+ --todo-muted: #737d89;
81
+
82
+ --todo-success: #22a06b;
83
+ --todo-danger: #d94b4b;
69
84
  }
70
85
 
71
86
  /* -------------------------------------------------------
@@ -136,5 +151,13 @@
136
151
  --b4um-hero-teaser-text: rgba(255, 255, 255, 0.85);
137
152
  --b4um-hero-teaser-border: rgba(255, 255, 255, 0.18);
138
153
 
154
+ /* todo */
155
+ --todo-background: #28292a;
156
+ --todo-surface: #222426;
157
+ --todo-border: #414448;
158
+
159
+ --todo-text: #e3e3e3;
160
+ --todo-muted: #a2a8ae;
161
+
139
162
  color-scheme: dark;
140
163
  }
@@ -0,0 +1,22 @@
1
+ <section id="todo_progress" class="b4um-todo__progress">
2
+ <div class="b4um-todo__progress-info">
3
+ <h2>Fortschritt</h2>
4
+
5
+ <span>
6
+ <%%= @completed_tasks %> von <%%= @total_tasks %> erledigt
7
+ </span>
8
+ </div>
9
+
10
+ <%% progress = @total_tasks.positive? ? (@completed_tasks * 100.0 / @total_tasks).round : 0 %>
11
+
12
+ <div class="b4um-todo__progress-bar">
13
+ <div
14
+ class="b4um-todo__progress-fill"
15
+ style="width: <%%= progress %>%"
16
+ ></div>
17
+ </div>
18
+
19
+ <p class="b4um-todo__progress-percentage">
20
+ <%%= progress %>% abgeschlossen
21
+ </p>
22
+ </section>
@@ -0,0 +1,42 @@
1
+ <div id="<%%= dom_id(task) %>"
2
+ class="b4um-todo__item <%%= 'b4um-todo__item--complete' if task.complete? %>">
3
+
4
+ <div class="b4um-todo__item-content">
5
+
6
+ <%%= button_to <%= singular_table_name %>_path(task),
7
+ method: :patch,
8
+ class: "b4um-todo__checkbox",
9
+ form: { data: { turbo: true } },
10
+ aria: {
11
+ label: task.complete? ? "Als offen markieren" : "Als erledigt markieren",
12
+ pressed: task.complete?
13
+ } do %>
14
+
15
+ <span class="b4um-todo__checkbox-icon">
16
+ <%%= "✓" if task.complete? %>
17
+ </span>
18
+
19
+ <%% end %>
20
+
21
+ <span class="b4um-todo__item-name">
22
+ <%%= task.name %>
23
+ </span>
24
+
25
+ </div>
26
+
27
+ <%%= button_to <%= singular_table_name %>_path(task),
28
+ method: :delete,
29
+ class: "b4um-todo__delete",
30
+ form: {
31
+ data: {
32
+ turbo: true,
33
+ turbo_confirm: "Möchtest du diese Aufgabe wirklich löschen?"
34
+ }
35
+ },
36
+ aria: { label: "Aufgabe löschen" } do %>
37
+
38
+ <span aria-hidden="true">×</span>
39
+
40
+ <%% end %>
41
+
42
+ </div>
@@ -0,0 +1,13 @@
1
+ class Create<%= class_name.pluralize %> < ActiveRecord::Migration[<%= migration_version %>]
2
+ def change
3
+ create_table :<%= plural_table_name %> do |t|
4
+ t.string :name, null: false
5
+ t.boolean :complete, default: false, null: false
6
+ <% if owner? %>
7
+ t.references :<%= owner_reference_name %>, null: false, foreign_key: true
8
+ <% end %>
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,101 @@
1
+ <header class="b4um-todo__header">
2
+ <h1>Meine Aufgaben</h1>
3
+ <p>Behalte deine Aufgaben im Blick.</p>
4
+ </header>
5
+ <div class="b4um-grid">
6
+ <div class="b4um-card b4um-card--full">
7
+ <div class="b4um-todo">
8
+ <%%= render "progress" %>
9
+
10
+ <section class="b4um-todo__form">
11
+ <h2>Neue Aufgabe</h2>
12
+
13
+ <%%= form_with model: @task,
14
+ data: {
15
+ controller: "b4um-todo",
16
+ action: "turbo:submit-end->b4um-todo#resetAfterSuccess"
17
+ } do |form| %>
18
+
19
+
20
+ <div class="b4um-todo__form-fields">
21
+
22
+ <div class="form-field">
23
+ <%%= form.text_field :name,
24
+ class: "form-input",
25
+ placeholder: " ",
26
+ required: true,
27
+ autofocus: true,
28
+ data: {
29
+ b4um_todo_target: "input",
30
+ action: "input->b4um-todo#updateSubmitState"
31
+ } %>
32
+
33
+ <%%= form.label :name,
34
+ "Was möchtest du erledigen?",
35
+ class: "form-label" %>
36
+ </div>
37
+
38
+ <%%= form.submit "Hinzufügen",
39
+ class: "b4um-todo__button",
40
+ data: {
41
+ b4um_todo_target: "submit"
42
+ } %>
43
+
44
+ </div>
45
+
46
+ <%% if @task.errors.any? %>
47
+ <div class="b4um-todo__errors">
48
+ <%%= @task.errors.full_messages.to_sentence %>
49
+ </div>
50
+ <%% end %>
51
+ <%% end %>
52
+ </section>
53
+
54
+ <section class="b4um-todo__section">
55
+ <h2>
56
+ Offene Aufgaben
57
+ <span id="incomplete_tasks_count">
58
+ (<%%= @incomplete_tasks.size %>)
59
+ </span>
60
+ </h2>
61
+
62
+ <div id="incomplete_tasks" class="b4um-todo__list">
63
+ <%%= render partial: "task",
64
+ collection: @incomplete_tasks,
65
+ as: :task %>
66
+ </div>
67
+
68
+ <div id="incomplete_tasks_empty">
69
+ <%% unless @incomplete_tasks.any? %>
70
+ <p class="b4um-todo__empty">
71
+ Keine offenen Aufgaben. Sehr gut!
72
+ </p>
73
+ <%% end %>
74
+ </div>
75
+ </section>
76
+
77
+ <section class="b4um-todo__section">
78
+ <h2>
79
+ Erledigte Aufgaben
80
+ <span id="complete_tasks_count">
81
+ (<%%= @complete_tasks.size %>)
82
+ </span>
83
+ </h2>
84
+
85
+ <div id="complete_tasks" class="b4um-todo__list">
86
+ <%%= render partial: "task",
87
+ collection: @complete_tasks,
88
+ as: :task %>
89
+ </div>
90
+
91
+ <div id="complete_tasks_empty">
92
+ <%% unless @complete_tasks.any? %>
93
+ <p class="b4um-todo__empty">
94
+ Noch keine erledigten Aufgaben.
95
+ </p>
96
+ <%% end %>
97
+ </div>
98
+ </section>
99
+ </div>
100
+ </div>
101
+ </div>
@@ -0,0 +1,7 @@
1
+ class <%= class_name %> < ApplicationRecord
2
+ <% if owner? %>
3
+ belongs_to :<%= owner_reference_name %>
4
+ <% end %>
5
+
6
+ validates :name, presence: true
7
+ end