cm-admin 3.0.15 → 3.0.16

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: a68921cd2290bc55a0fe8bad15e16cfdac64d9365756190a08c1e5ca45b35f57
4
- data.tar.gz: 56639a3c550354da66a09cff791cd342fef7e276ca627ab76124c07b1c593ac8
3
+ metadata.gz: f3debddacbd593b7ae649770a5237ea0af2f7c3481cfdb75f93adf833345c702
4
+ data.tar.gz: f2d63c47f670a66b78241fa45398edfac023c36acc89d079065734319e72bccd
5
5
  SHA512:
6
- metadata.gz: 3f11275fc5ddb6cd3793da121a5ea235b7f6ad0aba979edf3eb37d58800bf881ef55c43afd25e52cefc3b795b1feed6186c645f6a6fed6581cedc868a731e587
7
- data.tar.gz: f99f2472c8682e4517210b86aa5ebda52e7134b4f2fcfca4aa3418fae7f42773644852cc1bfd6b1cb7a3392fb4907c05033c79f4c9587805d8428af80b592963
6
+ metadata.gz: 7d04f7523d8e25ef11d45025a4e8adbb3f583c4d1c5b8e353cd30a7f0d055a79280cfe081a1120721f83377476ba074334d9ec01e822595b372e1c78f2c64217
7
+ data.tar.gz: 76b3873cc8a0bea1c6ec2bd435538c9e06304310000a77d7380e2fc9bbb46232734a6d1881ccb566ca7aa135679606dea7b374777b292092f1747a2736cc8adc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (3.0.15)
4
+ cm-admin (3.0.16)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -1,7 +1,7 @@
1
1
  import * as bootstrap from "bootstrap";
2
2
  window.bootstrap = bootstrap;
3
3
 
4
- document.addEventListener("turbo:load", function () {
4
+ export function handleFetchModalClick() {
5
5
  $('[data-action="fetch-modal"]').on("click", function (e) {
6
6
  const actionName = $(this).attr("data-action_name");
7
7
  const modelName = $(this).attr("data-model_name");
@@ -27,4 +27,8 @@ document.addEventListener("turbo:load", function () {
27
27
  },
28
28
  });
29
29
  });
30
+ }
31
+
32
+ document.addEventListener("turbo:load", function () {
33
+ handleFetchModalClick();
30
34
  });
@@ -1,3 +1,5 @@
1
+ import { handleFetchModalClick } from "./custom_action";
2
+
1
3
  var currentRequest = null;
2
4
 
3
5
  var CmFilter = {
@@ -123,6 +125,7 @@ var getFilteredData = function (
123
125
  dropdown.show();
124
126
  }
125
127
  }
128
+ handleFetchModalClick();
126
129
  },
127
130
  error: function (jqxhr, textStatus, errorThrown) {
128
131
  console.log(errorThrown, textStatus);
@@ -0,0 +1,53 @@
1
+ # Custom Filter Method
2
+
3
+ ## Overview
4
+
5
+ We can add a custom filter method to filter records based on specific criteria. This is useful when the default filtering options do not meet the requirements. The custom filter method can be defined using the `filter_with` option.
6
+
7
+ ## Usage
8
+
9
+ The custom filter method is implemented using the `filter` dsl_method with the `filter_with` option. Below are the key elements and their usage:
10
+
11
+ ### Syntax
12
+
13
+ ```ruby
14
+ filter :filter_name, :filter_type, filter_with: :custom_filter_method
15
+ ```
16
+
17
+ ### Example
18
+
19
+ **1. For Search and Select:**
20
+
21
+ Define the custom filter method in your model:
22
+
23
+ ```ruby
24
+ class YourModel < ApplicationRecord
25
+ scope :custom_filter_method, ->(value) { where('column_name LIKE ?', "%#{value}%") }
26
+ end
27
+ ```
28
+
29
+ Use the custom filter method in your cm admin:
30
+
31
+ ```ruby
32
+ filter :filter_name, :search, filter_with: :custom_filter_method
33
+ ```
34
+
35
+ ```ruby
36
+ filter :filter_name, :single_select, helper_method: :options_for_select, filter_with: :custom_filter_method
37
+ ```
38
+
39
+ **2. For Date and Range:**
40
+
41
+ Define the custom filter method in your model:
42
+
43
+ ```ruby
44
+ class YourModel < ApplicationRecord
45
+ scope :custom_filter_method, ->(from, to) { where('column_name BETWEEN ? AND ?', from, to) }
46
+ end
47
+ ```
48
+
49
+ Use the custom filter method in your cm admin:
50
+
51
+ ```ruby
52
+ filter :filter_name, :date, filter_with: :custom_filter_method
53
+ ```
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '3.0.15'
2
+ VERSION = '3.0.16'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cm-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.15
4
+ version: 3.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: exe
16
16
  cert_chain: []
17
- date: 2024-11-18 00:00:00.000000000 Z
17
+ date: 2024-11-25 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: caxlsx_rails
@@ -426,6 +426,7 @@ files:
426
426
  - config/webpack/test.js
427
427
  - config/webpacker.yml
428
428
  - docs/AddingAlert.md
429
+ - docs/CustomFilterMethod.md
429
430
  - docs/ListingSelectTwoAjax.md
430
431
  - docs/ListingSelectTwoItems.md
431
432
  - docs/RoleManagement.md