super 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -14
  3. data/app/assets/javascripts/super/application.js +191 -1
  4. data/app/controllers/super/application_controller.rb +14 -8
  5. data/app/helpers/super/form_builder_helper.rb +2 -0
  6. data/app/views/super/application/_filter.html.erb +5 -13
  7. data/app/views/super/application/_filter_type_select.html.erb +4 -1
  8. data/app/views/super/application/_filter_type_text.html.erb +5 -3
  9. data/app/views/super/application/_filter_type_timestamp.html.erb +5 -4
  10. data/app/views/super/application/_query.html.erb +18 -0
  11. data/app/views/super/application/_sort.html.erb +18 -0
  12. data/app/views/super/application/_sort_expression.html.erb +25 -0
  13. data/app/views/super/feather/README.md +1 -0
  14. data/app/views/super/feather/_x.html +15 -0
  15. data/config/routes.rb +2 -0
  16. data/docs/action_text.md +1 -1
  17. data/docs/yard_customizations.rb +2 -0
  18. data/frontend/super-frontend/dist/application.js +191 -1
  19. data/lib/generators/super/action_text/action_text_generator.rb +2 -0
  20. data/lib/generators/super/install/install_generator.rb +2 -0
  21. data/lib/generators/super/resource/resource_generator.rb +2 -0
  22. data/lib/generators/super/webpacker/webpacker_generator.rb +2 -0
  23. data/lib/super.rb +4 -1
  24. data/lib/super/action_inquirer.rb +2 -0
  25. data/lib/super/assets.rb +2 -0
  26. data/lib/super/client_error.rb +2 -0
  27. data/lib/super/compatibility.rb +2 -0
  28. data/lib/super/configuration.rb +2 -1
  29. data/lib/super/controls.rb +4 -0
  30. data/lib/super/controls/optional.rb +34 -1
  31. data/lib/super/controls/required.rb +2 -0
  32. data/lib/super/controls/steps.rb +27 -35
  33. data/lib/super/controls/view.rb +55 -0
  34. data/lib/super/display.rb +13 -5
  35. data/lib/super/display/guesser.rb +2 -0
  36. data/lib/super/display/schema_types.rb +2 -0
  37. data/lib/super/engine.rb +2 -0
  38. data/lib/super/error.rb +5 -0
  39. data/lib/super/filter.rb +2 -0
  40. data/lib/super/filter/form_object.rb +5 -8
  41. data/lib/super/filter/guesser.rb +2 -0
  42. data/lib/super/filter/operator.rb +2 -0
  43. data/lib/super/filter/schema_types.rb +2 -0
  44. data/lib/super/form.rb +2 -0
  45. data/lib/super/form/builder.rb +2 -0
  46. data/lib/super/form/guesser.rb +2 -0
  47. data/lib/super/form/inline_errors.rb +2 -0
  48. data/lib/super/form/schema_types.rb +2 -0
  49. data/lib/super/form/strong_params.rb +2 -0
  50. data/lib/super/layout.rb +2 -0
  51. data/lib/super/link.rb +2 -0
  52. data/lib/super/navigation/automatic.rb +2 -0
  53. data/lib/super/pagination.rb +2 -0
  54. data/lib/super/panel.rb +2 -0
  55. data/lib/super/partial.rb +2 -0
  56. data/lib/super/partial/resolving.rb +2 -0
  57. data/lib/super/plugin.rb +2 -0
  58. data/lib/super/query/form_object.rb +48 -0
  59. data/lib/super/schema.rb +2 -0
  60. data/lib/super/schema/common.rb +2 -0
  61. data/lib/super/schema/guesser.rb +2 -0
  62. data/lib/super/sort.rb +110 -0
  63. data/lib/super/version.rb +3 -1
  64. data/lib/super/view_helper.rb +2 -0
  65. metadata +23 -3
  66. data/lib/super/filter/plugin.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 043677dcee80c7b83903b21904f1768a411f807567190d7227928df9bf7922c7
4
- data.tar.gz: 5de2f073926089e4823a4228dc4f7be912fed0471d862f9b6f0f56dde280f154
3
+ metadata.gz: 05520525a7f38fff438eee43a134b9b2e52ac3551098c177323cdb87fd193670
4
+ data.tar.gz: 0db34e8d60114592b824ec79a2318a11743fe676291859ccec0d81615ce77bfb
5
5
  SHA512:
6
- metadata.gz: feeba0baacdaf977c16f9e785e7abf6637679ebe2f624716f1006cce290157e29157b046a01f3d287d1b826378a04ece8c482b59cd2f21dc53bf463a28cf2848
7
- data.tar.gz: a7d1a568a4c918ececb0200305f1e30042b4fc48946796f13e9568c27b5f95368b60aaac51ac977211566cb79f4973dd3d96a48a421531934c41884ce33ac084
6
+ metadata.gz: 489419d94f150b08399cfab907773f7cbafc08d7bbf6d2db3af0b8966b81b5cfc1d547fe1a8bb066f72fdac41b04d4b6295715468356de9442d66ae546ff890a
7
+ data.tar.gz: 806ca79ae33691eca540cd1350210ef4cf75fc427be26731068f307687e50643fe02999c473a39d90fe58f267e2f3aa5bd5e35d580c273b625f787c7176941b3
data/Rakefile CHANGED
@@ -1,33 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
- require 'bundler/setup'
4
+ require "bundler/setup"
3
5
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
7
  end
6
8
 
7
- require 'rdoc/task'
9
+ require "rdoc/task"
8
10
 
9
11
  RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Super'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "Super"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
17
  end
16
18
 
17
19
  require_relative "dummy_path"
18
20
 
19
21
  APP_RAKEFILE = File.expand_path("#{SUPER_DUMMY_PATH}/Rakefile", __dir__)
20
- load 'rails/tasks/engine.rake'
22
+ load "rails/tasks/engine.rake"
21
23
 
22
- load 'rails/tasks/statistics.rake'
24
+ load "rails/tasks/statistics.rake"
23
25
 
24
- require 'bundler/gem_tasks'
26
+ require "bundler/gem_tasks"
25
27
 
26
- require 'rake/testtask'
28
+ require "rake/testtask"
27
29
 
28
30
  Rake::TestTask.new(:test) do |t|
29
- t.libs << 'test'
30
- t.pattern = 'test/**/*_test.rb'
31
+ t.libs << "test"
32
+ t.pattern = "test/**/*_test.rb"
31
33
  t.verbose = false
32
34
  end
33
35
 
@@ -4332,6 +4332,187 @@ var _default = /*#__PURE__*/function (_Controller) {
4332
4332
  return _default;
4333
4333
  }(_stimulus.Controller);
4334
4334
 
4335
+ exports.default = _default;
4336
+ },{"stimulus":"../node_modules/stimulus/index.js"}],"javascripts/super/clean_filter_param_controller.js":[function(require,module,exports) {
4337
+ "use strict";
4338
+
4339
+ Object.defineProperty(exports, "__esModule", {
4340
+ value: true
4341
+ });
4342
+ exports.default = void 0;
4343
+
4344
+ var _stimulus = require("stimulus");
4345
+
4346
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4347
+
4348
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4349
+
4350
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4351
+
4352
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4353
+
4354
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
4355
+
4356
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4357
+
4358
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
4359
+
4360
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
4361
+
4362
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
4363
+
4364
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
4365
+
4366
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
4367
+
4368
+ var _default = /*#__PURE__*/function (_Controller) {
4369
+ _inherits(_default, _Controller);
4370
+
4371
+ var _super = _createSuper(_default);
4372
+
4373
+ function _default() {
4374
+ _classCallCheck(this, _default);
4375
+
4376
+ return _super.apply(this, arguments);
4377
+ }
4378
+
4379
+ _createClass(_default, [{
4380
+ key: "call",
4381
+ value: function call() {
4382
+ var allControlsBlank = this.controlTargets.every(function (el) {
4383
+ return el.value === "";
4384
+ });
4385
+
4386
+ if (!allControlsBlank) {
4387
+ return;
4388
+ }
4389
+
4390
+ this.candidateTargets.forEach(function (el) {
4391
+ el.disabled = true;
4392
+ });
4393
+ }
4394
+ }], [{
4395
+ key: "targets",
4396
+ get: function get() {
4397
+ return ["candidate", "control"];
4398
+ }
4399
+ }]);
4400
+
4401
+ return _default;
4402
+ }(_stimulus.Controller);
4403
+
4404
+ exports.default = _default;
4405
+ },{"stimulus":"../node_modules/stimulus/index.js"}],"javascripts/super/clean_filter_params_controller.js":[function(require,module,exports) {
4406
+ "use strict";
4407
+
4408
+ Object.defineProperty(exports, "__esModule", {
4409
+ value: true
4410
+ });
4411
+ exports.default = void 0;
4412
+
4413
+ var _stimulus = require("stimulus");
4414
+
4415
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4416
+
4417
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4418
+
4419
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4420
+
4421
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4422
+
4423
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
4424
+
4425
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4426
+
4427
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
4428
+
4429
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
4430
+
4431
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
4432
+
4433
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
4434
+
4435
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
4436
+
4437
+ var _default = /*#__PURE__*/function (_Controller) {
4438
+ _inherits(_default, _Controller);
4439
+
4440
+ var _super = _createSuper(_default);
4441
+
4442
+ function _default() {
4443
+ _classCallCheck(this, _default);
4444
+
4445
+ return _super.apply(this, arguments);
4446
+ }
4447
+
4448
+ _createClass(_default, [{
4449
+ key: "call",
4450
+ value: function call(event) {
4451
+ this.element.querySelectorAll("[data-controller='clean-filter-param']").forEach(function (el) {
4452
+ var controller = this.application.getControllerForElementAndIdentifier(el, "clean-filter-param");
4453
+ controller.call();
4454
+ }.bind(this));
4455
+ }
4456
+ }]);
4457
+
4458
+ return _default;
4459
+ }(_stimulus.Controller);
4460
+
4461
+ exports.default = _default;
4462
+ },{"stimulus":"../node_modules/stimulus/index.js"}],"javascripts/super/delete_controller.js":[function(require,module,exports) {
4463
+ "use strict";
4464
+
4465
+ Object.defineProperty(exports, "__esModule", {
4466
+ value: true
4467
+ });
4468
+ exports.default = void 0;
4469
+
4470
+ var _stimulus = require("stimulus");
4471
+
4472
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4473
+
4474
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4475
+
4476
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4477
+
4478
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4479
+
4480
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
4481
+
4482
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4483
+
4484
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
4485
+
4486
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
4487
+
4488
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
4489
+
4490
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
4491
+
4492
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
4493
+
4494
+ var _default = /*#__PURE__*/function (_Controller) {
4495
+ _inherits(_default, _Controller);
4496
+
4497
+ var _super = _createSuper(_default);
4498
+
4499
+ function _default() {
4500
+ _classCallCheck(this, _default);
4501
+
4502
+ return _super.apply(this, arguments);
4503
+ }
4504
+
4505
+ _createClass(_default, [{
4506
+ key: "call",
4507
+ value: function call(event) {
4508
+ event.preventDefault();
4509
+ this.element.remove();
4510
+ }
4511
+ }]);
4512
+
4513
+ return _default;
4514
+ }(_stimulus.Controller);
4515
+
4335
4516
  exports.default = _default;
4336
4517
  },{"stimulus":"../node_modules/stimulus/index.js"}],"javascripts/super/toggle_pending_destruction_controller.js":[function(require,module,exports) {
4337
4518
  "use strict";
@@ -4415,6 +4596,12 @@ var _stimulus = require("stimulus");
4415
4596
 
4416
4597
  var _apply_template_controller = _interopRequireDefault(require("./apply_template_controller"));
4417
4598
 
4599
+ var _clean_filter_param_controller = _interopRequireDefault(require("./clean_filter_param_controller"));
4600
+
4601
+ var _clean_filter_params_controller = _interopRequireDefault(require("./clean_filter_params_controller"));
4602
+
4603
+ var _delete_controller = _interopRequireDefault(require("./delete_controller"));
4604
+
4418
4605
  var _toggle_pending_destruction_controller = _interopRequireDefault(require("./toggle_pending_destruction_controller"));
4419
4606
 
4420
4607
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4425,5 +4612,8 @@ var StimulusApplication = _stimulus.Application.start();
4425
4612
 
4426
4613
  exports.StimulusApplication = StimulusApplication;
4427
4614
  StimulusApplication.register("apply-template", _apply_template_controller.default);
4615
+ StimulusApplication.register("clean-filter-param", _clean_filter_param_controller.default);
4616
+ StimulusApplication.register("clean-filter-params", _clean_filter_params_controller.default);
4617
+ StimulusApplication.register("delete", _delete_controller.default);
4428
4618
  StimulusApplication.register("toggle-pending-destruction", _toggle_pending_destruction_controller.default);
4429
- },{"@rails/ujs":"../node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js","stimulus":"../node_modules/stimulus/index.js","./apply_template_controller":"javascripts/super/apply_template_controller.js","./toggle_pending_destruction_controller":"javascripts/super/toggle_pending_destruction_controller.js"}]},{},["javascripts/super/application.js"], "Super")
4619
+ },{"@rails/ujs":"../node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js","stimulus":"../node_modules/stimulus/index.js","./apply_template_controller":"javascripts/super/apply_template_controller.js","./clean_filter_param_controller":"javascripts/super/clean_filter_param_controller.js","./clean_filter_params_controller":"javascripts/super/clean_filter_params_controller.js","./delete_controller":"javascripts/super/delete_controller.js","./toggle_pending_destruction_controller":"javascripts/super/toggle_pending_destruction_controller.js"}]},{},["javascripts/super/application.js"], "Super")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Super
2
4
  # Provides a default implementation for each of the resourceful actions
3
5
  class ApplicationController < ActionController::Base
@@ -9,22 +11,26 @@ module Super
9
11
  # Displays a list of records to the user
10
12
  def index
11
13
  @records = controls.load_records(action: action_inquirer, params: params)
12
- @display = controls.display_schema(action: action_inquirer)
13
- @view = controls.build_index_view
14
+ @display = controls.display_schema(action: action_inquirer).apply(action: action_inquirer)
15
+ @view = controls.index_view
16
+ @query_form = controls.initialize_query_form(params: params, current_path: request.path)
17
+ controls.initialize_filter_form(query_form: @query_form)
18
+ controls.initialize_sort_form(query_form: @query_form)
19
+ @records = controls.apply_queries(query_form: @query_form, records: @records)
14
20
  end
15
21
 
16
22
  # Displays a specific record to the user
17
23
  def show
18
24
  @record = controls.load_record(action: action_inquirer, params: params)
19
- @display = controls.display_schema(action: action_inquirer)
20
- @view = controls.build_show_view
25
+ @display = controls.display_schema(action: action_inquirer).apply(action: action_inquirer)
26
+ @view = controls.show_view
21
27
  end
22
28
 
23
29
  # Displays a form to allow the user to create a new record
24
30
  def new
25
31
  @record = controls.build_record(action: action_inquirer)
26
32
  @form = controls.form_schema(action: action_inquirer)
27
- @view = controls.build_new_view
33
+ @view = controls.new_view
28
34
  end
29
35
 
30
36
  # Creates a record, or shows the validation errors
@@ -35,7 +41,7 @@ module Super
35
41
  redirect_to polymorphic_path(Super.configuration.path_parts(@record))
36
42
  else
37
43
  @form = controls.form_schema(action: action_inquirer_for("new"))
38
- @view = controls.build_new_view
44
+ @view = controls.new_view
39
45
  render :new, status: :bad_request
40
46
  end
41
47
  end
@@ -44,7 +50,7 @@ module Super
44
50
  def edit
45
51
  @record = controls.load_record(action: action_inquirer, params: params)
46
52
  @form = controls.form_schema(action: action_inquirer)
47
- @view = controls.build_edit_view
53
+ @view = controls.edit_view
48
54
  end
49
55
 
50
56
  # Updates a record, or shows validation errors
@@ -55,7 +61,7 @@ module Super
55
61
  redirect_to polymorphic_path(Super.configuration.path_parts(@record))
56
62
  else
57
63
  @form = controls.form_schema(action: action_inquirer_for("edit"))
58
- @view = controls.build_edit_view
64
+ @view = controls.edit_view
59
65
  render :edit, status: :bad_request
60
66
  end
61
67
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Super
2
4
  module FormBuilderHelper
3
5
  def super_form_for(record, options = {}, &block)
@@ -1,14 +1,6 @@
1
- <%= render(Super::Panel.new) do %>
2
- <h1 class="text-xl">Filters</h1>
3
- <%= super_form_for(filter, url: filter.url, method: :get, as: :q, html: { class: "mt-4" }) do |form| %>
4
- <% filter.each_field do |filter_field| %>
5
- <div class="mt-4">
6
- <%= render(filter_field, form: form) %>
7
- </div>
8
- <% end %>
9
-
10
- <div>
11
- <%= form.super.submit "Filter", class: "super-button--border-gray mt-6" %>
12
- </div>
13
- <% end %>
1
+ <h1 class="text-lg">Filter</h1>
2
+ <% filter.each_field do |filter_field| %>
3
+ <div class="mt-4">
4
+ <%= render(filter_field, form: form) %>
5
+ </div>
14
6
  <% end %>
@@ -1,4 +1,4 @@
1
- <div class="super-field-group">
1
+ <div class="super-field-group" data-controller="clean-filter-param">
2
2
  <%= form.fields_for(filter_type_select.field_name, filter_type_select) do |form_field| %>
3
3
  <%= form_field.label(:q, filter_type_select.humanized_field_name) %>
4
4
  <div class="relative inline-block">
@@ -6,12 +6,15 @@
6
6
  :op,
7
7
  filter_type_select.operators,
8
8
  { include_blank: false },
9
+ data: { clean_filter_param_target: "candidate" }
9
10
  ) %>
10
11
  </div>
11
12
  <div class="mt-3">
12
13
  <%= form_field.super.select(
13
14
  :q,
14
15
  filter_type_select.field_type.collection,
16
+ {},
17
+ data: { clean_filter_param_target: "control candidate" }
15
18
  ) %>
16
19
  </div>
17
20
  <% end %>
@@ -1,16 +1,18 @@
1
- <div class="super-field-group">
1
+ <div class="super-field-group" data-controller="clean-filter-param">
2
2
  <%= form.fields_for(filter_type_text.field_name, filter_type_text) do |form_field| %>
3
3
  <%= form_field.label(:q, filter_type_text.humanized_field_name) %>
4
4
  <div class="relative inline-block">
5
5
  <%= form_field.super.select(
6
6
  :op,
7
7
  filter_type_text.operators,
8
- { include_blank: false }
8
+ { include_blank: false },
9
+ data: { clean_filter_param_target: "candidate" }
9
10
  ) %>
10
11
  </div>
11
12
  <%= form_field.super.text_field(
12
13
  :q,
13
- class: "mt-3"
14
+ class: "mt-3",
15
+ data: { clean_filter_param_target: "control candidate" }
14
16
  ) %>
15
17
  <% end %>
16
18
  </div>
@@ -1,22 +1,23 @@
1
- <div class="super-field-group">
1
+ <div class="super-field-group" data-controller="clean-filter-param">
2
2
  <%= form.fields_for(filter_type_timestamp.field_name, filter_type_timestamp) do |form_field| %>
3
3
  <%= form_field.label(:q0, filter_type_timestamp.humanized_field_name) %>
4
4
  <div class="relative inline-block mt-2">
5
5
  <%= form_field.super.select(
6
6
  :op,
7
7
  filter_type_timestamp.operators,
8
- { include_blank: false}
8
+ { include_blank: false },
9
+ data: { clean_filter_param_target: "candidate" }
9
10
  ) %>
10
11
  </div>
11
12
  <div class="flex items-center mt-3">
12
13
  <div class="flex-initial">
13
- <%= form_field.super.text_field(:q0) %>
14
+ <%= form_field.super.text_field(:q0, data: { clean_filter_param_target: "control candidate" }) %>
14
15
  </div>
15
16
  <div class="flex-initial px-2">
16
17
  &ndash;
17
18
  </div>
18
19
  <div class="flex-initial">
19
- <%= form_field.super.text_field(:q1) %>
20
+ <%= form_field.super.text_field(:q1, data: { clean_filter_param_target: "control candidate" }) %>
20
21
  </div>
21
22
  </div>
22
23
  <% end %>
@@ -0,0 +1,18 @@
1
+ <%= render(Super::Panel.new) do %>
2
+ <h1 class="text-xl">Query</h1>
3
+ <%= super_form_for(
4
+ query,
5
+ url: query.path,
6
+ method: :get,
7
+ as: query.namespace,
8
+ html: { class: "mt-4" },
9
+ data: { controller: "clean-filter-params", action: "submit->clean-filter-params#call" }) do |form| %>
10
+ <% query.addons.each do |namespace, addon| %>
11
+ <%= form.fields_for namespace do |addon_form| %>
12
+ <%= render(addon, form: addon_form) %>
13
+ <% end %>
14
+ <% end %>
15
+
16
+ <%= form.super.submit "Apply", class: "super-button--border-gray mt-6" %>
17
+ <% end %>
18
+ <% end %>