active_scaffold_batch 3.7.3 → 3.9.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 +4 -4
- data/README +101 -5
- data/app/assets/javascripts/active_scaffold_batch.js +10 -10
- data/app/assets/stylesshets/active_scaffold_batch.scss +4 -13
- data/app/views/active_scaffold_overrides/_batch_create_form.html.erb +8 -8
- data/app/views/active_scaffold_overrides/_batch_create_form_attribute.html.erb +7 -19
- data/app/views/active_scaffold_overrides/_batch_create_form_body.html.erb +24 -23
- data/app/views/active_scaffold_overrides/_batch_create_form_footer.html.erb +11 -2
- data/app/views/active_scaffold_overrides/_batch_create_form_horizontal.html.erb +24 -9
- data/app/views/active_scaffold_overrides/_batch_create_form_horizontal_record.html.erb +11 -26
- data/app/views/active_scaffold_overrides/_batch_create_form_multiple.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_batch_create_form_vertical.html.erb +12 -3
- data/app/views/active_scaffold_overrides/_batch_create_form_vertical_record.html.erb +5 -5
- data/app/views/active_scaffold_overrides/_batch_update_form.html.erb +6 -6
- data/app/views/active_scaffold_overrides/_batch_update_form_attribute.html.erb +1 -11
- data/app/views/active_scaffold_overrides/_batch_update_form_attribute_scope.html.erb +7 -12
- data/app/views/active_scaffold_overrides/_batch_update_form_body.html.erb +24 -23
- data/app/views/active_scaffold_overrides/_form_messages.html.erb +16 -4
- data/app/views/active_scaffold_overrides/batch_add.js.erb +16 -3
- data/app/views/active_scaffold_overrides/batch_create.html.erb +1 -1
- data/app/views/active_scaffold_overrides/batch_update.html.erb +1 -1
- data/app/views/active_scaffold_overrides/on_batch_base.js.erb +14 -4
- data/app/views/active_scaffold_overrides/on_batch_create.js.erb +10 -5
- data/app/views/active_scaffold_overrides/on_batch_update.js.erb +6 -4
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es.yml +2 -1
- data/lib/active_scaffold/actions/batch_base.rb +23 -28
- data/lib/active_scaffold/actions/batch_create.rb +78 -44
- data/lib/active_scaffold/actions/batch_destroy.rb +16 -15
- data/lib/active_scaffold/actions/batch_update.rb +129 -104
- data/lib/active_scaffold/config/batch_create.rb +17 -19
- data/lib/active_scaffold/config/batch_destroy.rb +24 -14
- data/lib/active_scaffold/config/batch_update.rb +21 -20
- data/lib/active_scaffold/helpers/batch_create_column_helpers.rb +17 -18
- data/lib/active_scaffold/helpers/datepicker_update_column_helpers.rb +48 -17
- data/lib/active_scaffold/helpers/update_column_helpers.rb +91 -33
- data/lib/active_scaffold_batch/engine.rb +10 -12
- data/lib/active_scaffold_batch/extensions.rb +16 -0
- data/lib/active_scaffold_batch/version.rb +4 -2
- data/lib/active_scaffold_batch.rb +5 -15
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1e1ce7c79235a8e002895fd16c2e61dfd2f9446bdae44dd8b8911b3e3476b1f
|
|
4
|
+
data.tar.gz: d2c9a00ae21cb124dc52eca08773a0731d024b2ee164344eb1f4d403c4f82b12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddbcd3f617626824a33eb523aa7b84b88f2db4be98163694b8c42c98496f930f3ef077105e5b868e805b6a7dd1d0a7bf17c94efcb9cc3fa136a0124ea2a096ee
|
|
7
|
+
data.tar.gz: 52939666dbfa33f70637eb77d2ee0b2344de7130609e3957c8e2b5bbb2f135b6119a36a6d2238295519b9d6d747216e883103be468de270293a3527252be7113
|
data/README
CHANGED
|
@@ -1,12 +1,108 @@
|
|
|
1
|
-
|
|
1
|
+
# ActiveScaffold Batch
|
|
2
2
|
|
|
3
|
+
ActiveScaffold Batch adds actions for creating, updating, and deleting multiple records from an ActiveScaffold list.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
The upcoming 3.8 release requires ActiveScaffold 4.4 or newer. Use ActiveScaffold Batch 3.7.x with older ActiveScaffold releases.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add the gem to your `Gemfile`:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
3
14
|
gem 'active_scaffold_batch'
|
|
15
|
+
```
|
|
4
16
|
|
|
5
|
-
|
|
6
|
-
Use 3.3.x for rails 3.2.x.
|
|
17
|
+
Then run `bundle install`.
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
## Enable actions
|
|
9
20
|
|
|
10
|
-
|
|
21
|
+
Enable only the actions an application needs:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
class UsersController < ApplicationController
|
|
25
|
+
active_scaffold :user do |config|
|
|
11
26
|
config.actions.add :batch_update
|
|
12
27
|
config.actions.add :batch_destroy
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The plugin provides `batch_create`, `batch_update`, and `batch_destroy`. Batch Update and Batch Destroy can operate on every record in the current filtered list. When the `mark` action is enabled, they can also operate only on marked records.
|
|
33
|
+
|
|
34
|
+
## Batch Create
|
|
35
|
+
|
|
36
|
+
Batch Create has two distinct modes.
|
|
37
|
+
|
|
38
|
+
With no `default_batch_by_column`, it is a multiple-row create form. It initially displays one new record and lets the user add more blank rows before submitting them together:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
config.actions.add :batch_create
|
|
42
|
+
config.batch_create.layout = :vertical # or :horizontal
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
With `default_batch_by_column`, one form is applied once for every selected value of that column. For example, the following configuration creates one player for each selected team while sharing the other entered player attributes:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
config.actions.add :batch_create
|
|
49
|
+
config.batch_create.default_batch_by_column = :team
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The batch column may be a `belongs_to` association or a scalar column. For a scalar column, enter one value per line.
|
|
53
|
+
|
|
54
|
+
By default, Batch Create validates and saves all records in one transaction and rolls everything back when any record fails. The supported settings are:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
config.batch_create.run_in_transaction = true
|
|
58
|
+
config.batch_create.layout = :vertical
|
|
59
|
+
config.batch_create.list_mode_enabled = true
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Set `run_in_transaction` to `false` to retain successful records when another row fails, or to `:validate_first` to validate every record before saving any of them.
|
|
63
|
+
|
|
64
|
+
## Batch Update
|
|
65
|
+
|
|
66
|
+
Batch Update presents an operator for each editable column. `NO_UPDATE` leaves the column unchanged and `REPLACE` assigns the entered value. Numeric columns also support addition, subtraction, multiplication, and division with absolute or percentage operands. Date columns support addition and subtraction.
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
config.actions.add :batch_update
|
|
70
|
+
config.batch_update.list_mode_enabled = true
|
|
71
|
+
config.batch_update.process_mode = :update
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The default `:update` mode instantiates every record and runs authorization, validations, and callbacks. `:update_all` performs direct SQL updates and skips those model callbacks and validations.
|
|
75
|
+
|
|
76
|
+
## Batch Destroy
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
config.actions.add :batch_destroy
|
|
80
|
+
config.batch_destroy.process_mode = :delete
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The default `:delete` mode processes records individually through ActiveScaffold. `:delete_all` uses direct SQL and skips model callbacks. Both modes expose separate links for the current filtered list and, when marking is enabled, marked records.
|
|
84
|
+
|
|
85
|
+
## UI adapter support
|
|
86
|
+
|
|
87
|
+
Version 3.8 reuses ActiveScaffold 4.4's standard form elements. Refer to ActiveScaffold's UI element reference for `form`, `form_title`, `fields_container`, `form_element`, `form_attribute`, `form_control`, form footer controls, and the other shared elements.
|
|
88
|
+
|
|
89
|
+
Batch defines only one plugin-specific element:
|
|
90
|
+
|
|
91
|
+
| Element | Type | Used for |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `batch_create_add_rows` | Attributes only | Remote link that adds blank rows to a multiple-row Batch Create form. |
|
|
94
|
+
|
|
95
|
+
For example, an adapter can customize the Batch-specific add-row link without replacing its template:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
ActiveScaffold.add_element_attributes :batch_create_add_rows,
|
|
99
|
+
class: 'btn btn-sm btn-secondary'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Batch-specific inputs use the shared `form_control` element. Its proc receives the usual `column` and `form_ui` context plus `batch_role`, which identifies `batch_scope`, `batch_update_operator`, `batch_update_value`, `batch_update_numeric_option`, `batch_update_date_amount`, `batch_update_date_unit`, or `batch_create_row_count`. This lets an adapter distinguish the controls when necessary without adding a separate registry element for each one.
|
|
103
|
+
|
|
104
|
+
The shared elements use the same definitions as ActiveScaffold's ordinary forms, so one adapter configuration keeps core and Batch forms consistent.
|
|
105
|
+
|
|
106
|
+
## Safety
|
|
107
|
+
|
|
108
|
+
List-scoped actions affect the complete filtered result, not only the visible page. Prefer marked-record scope for destructive operations when the user should explicitly select every affected record. Use the per-record processing modes when callbacks, validations, or authorization checks are required.
|
|
@@ -4,16 +4,16 @@ jQuery(document).ready(function() {
|
|
|
4
4
|
if (num_records) settings.url += (settings.url.indexOf('?') != -1 ? '&' : '?') + 'num_records=' + num_records;
|
|
5
5
|
return true;
|
|
6
6
|
});
|
|
7
|
-
jQuery(document).on('
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
jQuery(document).on('change', '.as_update_date_operator, .as_batch_update_operator, .as_update_numeric_option', function(event) {
|
|
8
|
+
var $op = jQuery(this), method,
|
|
9
|
+
fields = $op.closest('.form-element').find(':input, .mceEditor + div').not(this).filter(function() {
|
|
10
|
+
return jQuery(this).closest('.search-date-trend').length === 0;
|
|
11
|
+
});
|
|
12
|
+
if ($op.is('.as_update_date_operator')) method = $op.val() === 'REPLACE' ? 'show' : 'hide';
|
|
13
|
+
else method = ['NO_UPDATE', 'NULL'].indexOf(jQuery(this).val()) !== -1 ? 'hide' : 'show';
|
|
14
|
+
ActiveScaffold[method](fields);
|
|
12
15
|
});
|
|
13
|
-
jQuery(document).on('change', '
|
|
14
|
-
ActiveScaffold[jQuery(this).val()
|
|
15
|
-
});
|
|
16
|
-
jQuery(document).on('change', 'select.as_update_date_operator', function(event) {
|
|
17
|
-
ActiveScaffold[['REPLACE', 'NO_UPDATE', 'NULL'].indexOf(jQuery(this).val()) !== -1 ? 'hide' : 'show'](jQuery(this).next().next());
|
|
16
|
+
jQuery(document).on('change', '.as_update_date_operator', function(event) {
|
|
17
|
+
ActiveScaffold[['REPLACE', 'NO_UPDATE', 'NULL'].indexOf(jQuery(this).val()) !== -1 ? 'hide' : 'show'](jQuery(this).closest('.form-element').find('.search-date-trend'));
|
|
18
18
|
});
|
|
19
19
|
});
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
.active-scaffold .multiple .
|
|
1
|
+
.active-scaffold .multiple .sub-form-record .errorExplanation {
|
|
2
2
|
clear: left;
|
|
3
3
|
margin-top: 10px;
|
|
4
4
|
}
|
|
5
|
-
.active-scaffold .multiple .
|
|
5
|
+
.active-scaffold .multiple .sub-form-record {
|
|
6
6
|
border-top: 1px solid #7FCF00;
|
|
7
7
|
}
|
|
8
|
-
.active-scaffold .multiple .
|
|
8
|
+
.active-scaffold .multiple thead + .sub-form-record,
|
|
9
|
+
.active-scaffold .multiple .sub-form-record:first-child {
|
|
9
10
|
border-top: 0;
|
|
10
11
|
}
|
|
11
|
-
.active-scaffold .multiple .form_record a.remove {
|
|
12
|
-
background-image: image-url("active_scaffold/cross.png");
|
|
13
|
-
display: block;
|
|
14
|
-
font-weight: bold;
|
|
15
|
-
height: 16px;
|
|
16
|
-
padding: 0;
|
|
17
|
-
text-indent: -4000px;
|
|
18
|
-
width: 16px;
|
|
19
|
-
margin: 0 5px 10px;
|
|
20
|
-
}
|
|
21
12
|
.batch-create-rows {
|
|
22
13
|
float: right;
|
|
23
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<%= render
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<%= render 'base_form', {xhr: local_assigns.fetch(:xhr, nil),
|
|
2
|
+
form_action: local_assigns.fetch(:form_action, :batch_create),
|
|
3
|
+
method: local_assigns.fetch(:method, :post),
|
|
4
|
+
cancel_link: local_assigns.fetch(:cancel_link, true),
|
|
5
|
+
body_partial: batch_create_by_column ? 'batch_create_form_body' : 'batch_create_form_multiple',
|
|
6
|
+
footer_extension: ('batch_create_form_footer' unless batch_create_by_column),
|
|
7
|
+
scope: @scope,
|
|
8
|
+
headline: local_assigns.fetch(:headline, active_scaffold_config.batch_create.label)} %>
|
|
9
9
|
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
<%
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<%= active_scaffold_batch_create_by_column column, scope, :object => record %>
|
|
9
|
-
<% else %>
|
|
10
|
-
<%= active_scaffold_input_for column, scope, options %>
|
|
11
|
-
<% if column.update_columns -%>
|
|
12
|
-
<%= loading_indicator_tag(:action => :render_field, :id => params[:id]) %>
|
|
13
|
-
<% end -%>
|
|
14
|
-
<% end %>
|
|
15
|
-
<% if column.description -%>
|
|
16
|
-
<span class="description"><%= column.description %></span>
|
|
17
|
-
<% end -%>
|
|
18
|
-
</dd>
|
|
19
|
-
</dl>
|
|
1
|
+
<%
|
|
2
|
+
scope ||= nil
|
|
3
|
+
if column == batch_create_by_column.to_sym
|
|
4
|
+
field = active_scaffold_batch_create_by_column column, scope, object: record
|
|
5
|
+
end
|
|
6
|
+
%>
|
|
7
|
+
<%= form_attribute(column, record, scope, field: field) %>
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
<%
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<%
|
|
2
|
+
ol_attrs = {}
|
|
3
|
+
ol_attrs[:id] = subsection_id unless local_assigns[:subsection_id].nil?
|
|
4
|
+
ol_attrs[:style] = 'display: none;' if columns.collapsed
|
|
5
|
+
%>
|
|
6
|
+
<%= as_element :fields_container, class: 'form', **ol_attrs do %>
|
|
7
|
+
<%= as_element :form_element, hidden_field_tag('batch_scope', batch_scope || 'LISTED') %>
|
|
8
|
+
|
|
6
9
|
<% columns.each_column(for: @record) do |column| %>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<%
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</li>
|
|
10
|
+
<% next unless column.association.nil? || column.association.belongs_to? %>
|
|
11
|
+
|
|
12
|
+
<% column_css_class = column.css_class unless column.css_class.is_a?(Proc) %>
|
|
13
|
+
<% renders_as = column_renders_as(column) %>
|
|
14
|
+
<% if renders_as == :subsection -%>
|
|
15
|
+
<%= as_element :form_subsection, class: column_css_class do %>
|
|
16
|
+
<%= render_subsection(column, @record, scope, form_action) %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% elsif column.association.try(:readonly?) %>
|
|
19
|
+
<% next %>
|
|
20
|
+
<% else %>
|
|
21
|
+
<%= as_element :form_element, class: "form-element #{column_css_class}" do %>
|
|
22
|
+
<%= render 'batch_create_form_attribute', column: column, record: @record %>
|
|
23
|
+
<% end -%>
|
|
24
|
+
<% end -%>
|
|
23
25
|
<% end -%>
|
|
24
|
-
|
|
25
|
-
</ol>
|
|
26
|
+
<% end %>
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
<span class='batch-create-rows'>
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
<%
|
|
3
|
+
number_attributes = active_scaffold_batch_control_attributes(nil, :number, :batch_create_row_count, id: nil)
|
|
4
|
+
number_input = text_field_tag(:num_records, 1, active_scaffold_input_text_options(number_attributes))
|
|
5
|
+
add_records_text = as_(
|
|
6
|
+
:add_some_records,
|
|
7
|
+
model: active_scaffold_config.label(count: 2),
|
|
8
|
+
number_input: number_input
|
|
9
|
+
)
|
|
10
|
+
%>
|
|
11
|
+
<%= add_records_text %>
|
|
12
|
+
<%= link_to as_(:add), params_for(action: :batch_add), as_element_attributes(:batch_create_add_rows, remote: true) %>
|
|
4
13
|
</span>
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
<div class="form sub-form horizontal-sub-form">
|
|
2
|
-
<table cellpadding="0" cellspacing="0">
|
|
3
|
-
|
|
2
|
+
<table cellpadding="0" cellspacing="0" id="<%= element_form_id action: form_action %>-content" class="multiple">
|
|
3
|
+
<%
|
|
4
|
+
header_locals = {
|
|
5
|
+
columns: columns,
|
|
6
|
+
scope: nil,
|
|
7
|
+
record_class: records.values.first.class,
|
|
8
|
+
crud_type: columns.action.crud_type,
|
|
9
|
+
parent_record: nil,
|
|
10
|
+
parent_column: nil
|
|
11
|
+
}
|
|
12
|
+
%>
|
|
13
|
+
<%= render 'horizontal_subform_header', header_locals %>
|
|
4
14
|
|
|
5
|
-
|
|
6
|
-
<%
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
<% records.each.with_index do |(scope, record), index| %>
|
|
16
|
+
<%
|
|
17
|
+
record_locals = {
|
|
18
|
+
columns: columns,
|
|
19
|
+
form_action: form_action,
|
|
20
|
+
scope: "[#{scope}]",
|
|
21
|
+
first: index.zero?,
|
|
22
|
+
record: record
|
|
23
|
+
}
|
|
24
|
+
%>
|
|
25
|
+
<%= render 'batch_create_form_horizontal_record', record_locals %>
|
|
26
|
+
<% end -%>
|
|
12
27
|
</table>
|
|
13
28
|
</div>
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
<% first = true unless local_assigns.has_key? :first -%>
|
|
2
|
-
<% if record.errors.count -%>
|
|
3
|
-
<tr class="form_record-errors">
|
|
4
|
-
<td colspan="<%= columns.length + 1 %>" id="<%= element_messages_id :action => record.class.name.underscore %>">
|
|
5
|
-
<%= active_scaffold_error_messages_for :record, :object_name => record.class.model_name.human.downcase %>
|
|
6
|
-
</td>
|
|
7
|
-
</tr>
|
|
8
|
-
<% end %>
|
|
9
|
-
<tr class="form_record">
|
|
10
|
-
<% columns.each_column(flatten: true) do |column| -%>
|
|
11
1
|
<%
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<%= render_column(column, record, renders_as, scope) %>
|
|
24
|
-
</td>
|
|
25
|
-
<% end -%>
|
|
26
|
-
<td><%= batch_create_multiple_remove_link unless first %></td>
|
|
27
|
-
</tr>
|
|
2
|
+
association_locals = {
|
|
3
|
+
scope: scope,
|
|
4
|
+
column: nil,
|
|
5
|
+
parent_record: nil,
|
|
6
|
+
columns: columns,
|
|
7
|
+
layout: :horizontal,
|
|
8
|
+
locked: first,
|
|
9
|
+
record: record
|
|
10
|
+
}
|
|
11
|
+
%>
|
|
12
|
+
<%= render 'form_association_record', association_locals %>
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
{scope => @record}
|
|
6
6
|
end
|
|
7
7
|
-%>
|
|
8
|
-
<%= render
|
|
8
|
+
<%= render batch_create_multiple_layout, columns: columns, form_action: form_action, records: records %>
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
<div id="<%= element_form_id :
|
|
1
|
+
<div id="<%= element_form_id action: form_action %>-content" class="multiple">
|
|
2
2
|
<%
|
|
3
3
|
first = true
|
|
4
4
|
original_record = @record
|
|
5
5
|
-%>
|
|
6
6
|
<% records.each do |scope, record| -%>
|
|
7
7
|
<% @record = record %>
|
|
8
|
-
|
|
8
|
+
<%
|
|
9
|
+
record_locals = {
|
|
10
|
+
columns: columns,
|
|
11
|
+
form_action: form_action,
|
|
12
|
+
scope: "[#{scope}]",
|
|
13
|
+
first: first,
|
|
14
|
+
record: record
|
|
15
|
+
}
|
|
16
|
+
%>
|
|
17
|
+
<%= render 'batch_create_form_vertical_record', record_locals %>
|
|
9
18
|
<% first = false -%>
|
|
10
19
|
<% end -%>
|
|
11
20
|
</div>
|
|
12
|
-
<% @record = original_record %>
|
|
21
|
+
<% @record = original_record %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<% first = true unless local_assigns.
|
|
2
|
-
<div class="
|
|
3
|
-
<%= render
|
|
4
|
-
<%= render
|
|
5
|
-
<%=
|
|
1
|
+
<% first = true unless local_assigns.key? :first -%>
|
|
2
|
+
<div class="sub-form-record">
|
|
3
|
+
<%= render 'form_messages' %>
|
|
4
|
+
<%= render 'form', {columns: columns, form_action: form_action, scope: scope} %>
|
|
5
|
+
<%= link_to(as_(:remove), '#', as_element_attributes(:subform_record_remove, class: 'destroy')) unless first %>
|
|
6
6
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<%= render
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<%= render 'base_form', {xhr: local_assigns.fetch(:xhr, nil),
|
|
2
|
+
form_action: local_assigns.fetch(:form_action, :batch_update),
|
|
3
|
+
method: local_assigns.fetch(:method, :post),
|
|
4
|
+
cancel_link: local_assigns.fetch(:cancel_link, true),
|
|
5
|
+
body_partial: 'batch_update_form_body',
|
|
6
|
+
headline: local_assigns.fetch(:headline, active_scaffold_config.batch_update.label)} %>
|
|
7
7
|
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
<% scope ||= nil %>
|
|
2
|
-
|
|
3
|
-
<dt>
|
|
4
|
-
<label for="<%= active_scaffold_input_options(column, scope)[:id] %>"><%= column.label %></label>
|
|
5
|
-
</dt>
|
|
6
|
-
<dd>
|
|
7
|
-
<%= active_scaffold_update_for column, scope, :object => record %>
|
|
8
|
-
<% if column.description -%>
|
|
9
|
-
<span class="description"><%= column.description %></span>
|
|
10
|
-
<% end -%>
|
|
11
|
-
</dd>
|
|
12
|
-
</dl>
|
|
2
|
+
<%= form_attribute(column, record, scope, field: active_scaffold_update_for(column, scope, object: record)) %>
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
<%
|
|
2
|
-
scope_select_options = active_scaffold_update_scope_select_options
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<%
|
|
2
|
+
scope_select_options = active_scaffold_update_scope_select_options
|
|
3
|
+
field = active_scaffold_update_scope_select(scope_select_options)
|
|
4
|
+
%>
|
|
5
|
+
<% if active_scaffold_update_scope_select_hidden? %>
|
|
6
|
+
<%= field %>
|
|
5
7
|
<% else %>
|
|
6
|
-
|
|
7
|
-
<dt>
|
|
8
|
-
<label for="record_batch_scope"><%= as_(:records) %></label>
|
|
9
|
-
</dt>
|
|
10
|
-
<dd>
|
|
11
|
-
<%= active_scaffold_update_scope_select(scope_select_options) %>
|
|
12
|
-
</dd>
|
|
13
|
-
</dl>
|
|
8
|
+
<%= form_attribute_html(nil, label_tag('record_batch_scope', as_(:records)), field, nil, {}) %>
|
|
14
9
|
<% end %>
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
<%
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<%
|
|
2
|
+
ol_attrs = {}
|
|
3
|
+
ol_attrs[:id] = subsection_id unless local_assigns[:subsection_id].nil?
|
|
4
|
+
ol_attrs[:style] = 'display: none;' if columns.collapsed
|
|
5
|
+
%>
|
|
6
|
+
<%= as_element :fields_container, class: 'form', **ol_attrs do %>
|
|
7
|
+
<%= as_element :form_element, render('batch_update_form_attribute_scope'), class: 'form-element' %>
|
|
8
|
+
|
|
6
9
|
<% columns.each_column(for: @record) do |column| %>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<%
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</li>
|
|
10
|
+
<% next unless column.association.nil? || column.association.belongs_to? %>
|
|
11
|
+
|
|
12
|
+
<% column_css_class = column.css_class unless column.css_class.is_a?(Proc) %>
|
|
13
|
+
<% renders_as = column_renders_as(column) %>
|
|
14
|
+
<% if renders_as == :subsection -%>
|
|
15
|
+
<%= as_element :form_subsection, class: column_css_class do %>
|
|
16
|
+
<%= render_subsection(column, @record, scope, form_action) %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% elsif column.association.try(:readonly?) %>
|
|
19
|
+
<% next %>
|
|
20
|
+
<% else %>
|
|
21
|
+
<%= as_element :form_element, class: "form-element #{column_css_class}" do %>
|
|
22
|
+
<%= render 'batch_update_form_attribute', column: column, record: @record %>
|
|
23
|
+
<% end -%>
|
|
24
|
+
<% end -%>
|
|
23
25
|
<% end -%>
|
|
24
|
-
|
|
25
|
-
</ol>
|
|
26
|
+
<% end %>
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
<% if @error_records.present? && @error_records.is_a?(Array) -%>
|
|
2
|
-
<%= render
|
|
2
|
+
<%= render 'messages' unless request.xhr? %>
|
|
3
3
|
|
|
4
|
-
<%
|
|
4
|
+
<%
|
|
5
|
+
if batch_create_by_column && active_scaffold_config.columns[batch_create_by_column].association.nil?
|
|
6
|
+
id_column = active_scaffold_config.model.human_attribute_name(batch_create_by_column)
|
|
7
|
+
end
|
|
8
|
+
%>
|
|
5
9
|
<% @error_records.each do |record| %>
|
|
6
|
-
<%
|
|
7
|
-
|
|
10
|
+
<%
|
|
11
|
+
record_title =
|
|
12
|
+
if record.new_record?
|
|
13
|
+
id_column ? "(#{id_column} #{record.send(batch_create_by_column)})" : ''
|
|
14
|
+
else
|
|
15
|
+
record.to_label
|
|
16
|
+
end
|
|
17
|
+
object_name = "#{record.class.model_name.human.downcase} #{record_title}"
|
|
18
|
+
%>
|
|
19
|
+
<%= active_scaffold_error_messages_for record, object_name: object_name %>
|
|
8
20
|
<% end %>
|
|
9
21
|
<% else %>
|
|
10
22
|
<%= render :super %>
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
<%
|
|
1
|
+
<% rows = [] -%>
|
|
2
2
|
<% @records.each do |scope, record| -%>
|
|
3
|
-
<%
|
|
3
|
+
<%
|
|
4
|
+
record_locals = {
|
|
5
|
+
columns: active_scaffold_config.batch_create.columns,
|
|
6
|
+
form_action: :batch_create,
|
|
7
|
+
scope: "[#{scope}]",
|
|
8
|
+
first: false,
|
|
9
|
+
record: record
|
|
10
|
+
}
|
|
11
|
+
rows << render("#{batch_create_multiple_layout}_record", record_locals)
|
|
12
|
+
%>
|
|
4
13
|
<% end %>
|
|
5
|
-
ActiveScaffold.create_associated_record_form(
|
|
14
|
+
ActiveScaffold.create_associated_record_form(
|
|
15
|
+
'<%= element_form_id(action: :batch_create) %>-content',
|
|
16
|
+
'<%= escape_javascript(safe_join(rows)) %>',
|
|
17
|
+
{singular: false}
|
|
18
|
+
);
|
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
if @error_records.empty?
|
|
3
3
|
flash[:info] = as_(:batch_processing_successful) if flash[:info].blank?
|
|
4
4
|
else
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
messages = @error_records.collect do |_, record|
|
|
6
|
+
record_name = record.class.model_name.human.downcase
|
|
7
|
+
record_name += ": #{record.to_label}" unless record.new_record?
|
|
8
|
+
active_scaffold_error_messages_for(
|
|
9
|
+
record,
|
|
10
|
+
object_name: record_name,
|
|
11
|
+
header_message: '',
|
|
12
|
+
message: record_name,
|
|
13
|
+
container_tag: nil,
|
|
14
|
+
list_type: :br
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
flash[:error] = safe_join(messages)
|
|
8
18
|
end
|
|
9
19
|
%>
|
|
10
|
-
ActiveScaffold.replace_html('<%= active_scaffold_content_id%>','<%=escape_javascript(render(
|
|
20
|
+
ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%=escape_javascript(render('list'))%>');
|