comee_core 0.2.16 → 0.2.18

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: 406c93dca731f87dea5f764260975fb10ea432aa054d6b619faaf0a4430af097
4
- data.tar.gz: ca8d491fc263c2cd7abc3618f8dc1a54ff544137674936527ed3e2511c299033
3
+ metadata.gz: 0a22a79a452e5e9f9f66bf84f7fd4d986765f2fe7d9fbc9e228b8cf6963a33d4
4
+ data.tar.gz: ca63072349143672a4e0e20eaf3ed5668414d1a36e7cebccea91efd9779c2f71
5
5
  SHA512:
6
- metadata.gz: 9d77f8b9c8ab3e2dcf258faf3312a7f44698f608a7c59a7a024c3a361261b348f17c1868f7685579ffef5db0d63c1a76e95b2d81f8f1eca4c3cd2ef7216bbd37
7
- data.tar.gz: c0ac3ee94586168c23566ca9ef133c4b092d66cf6ac764d152e1a5c8fb37f4ae051db50eaa4ab14f42efb7a4bb0198648a4e6d6a99c2f9fb60ce785f2f2b02c6
6
+ metadata.gz: b0c350b679889199287028a5ca3fe90e70f1b3f78ee9eb204793f782dbdea1880e878bae5b6715b0f00f148781fcdf950e1383c5818b47019d2159b8f5a440ae
7
+ data.tar.gz: e660b422111cb6e69c8befe2e0e8e2fc28a91b3fe9376fc491b7ac933db352eb31cb0977f28d8998d9499c3d0890f44a82dbbcdd0997fb2dbf8cb2b52b16219e
@@ -58,7 +58,7 @@ module Comee
58
58
 
59
59
  def filter
60
60
  orders = CustomerOrder.includes(:client, :customer_order_items).ransack(params[:q]).result
61
- render_content(orders)
61
+ render_content(orders, fields: ["client", "customer_order_items.unit"])
62
62
  end
63
63
 
64
64
  private
@@ -27,6 +27,12 @@ module Comee
27
27
  render_content(item)
28
28
  end
29
29
 
30
+ def activate
31
+ item = set_object
32
+ item.update(canceled: false)
33
+ render_content(item)
34
+ end
35
+
30
36
  def destroy
31
37
  Comee::Core::SalesOrderItem.destroy(params[:id])
32
38
  render json: {success: true}
@@ -23,13 +23,19 @@ module Comee
23
23
  end
24
24
  end
25
25
 
26
+ def update
27
+ super do
28
+ {fields: ["client", "customer_order", "sales_order_items", "sales_order_items.product", "sales_order_items.unit"]}
29
+ end
30
+ end
31
+
26
32
  def filter
27
33
  data = SalesOrder.includes(
28
34
  :customer_order,
29
35
  :client,
30
36
  sales_order_items: :unit
31
37
  ).ransack(params[:q]).result
32
- render_content(data)
38
+ render_content(data, fields: ["client", "customer_order", "sales_order_items.product", "sales_order_items.unit"])
33
39
  end
34
40
 
35
41
  def submit
@@ -61,13 +61,28 @@ module Comee
61
61
  end
62
62
 
63
63
  def create
64
- obj = if block_given?
65
- yield
66
- else
67
- @clazz.new(model_params)
68
- end
64
+ obj = nil
65
+ options = {}
66
+ if block_given?
67
+ incoming = yield
68
+ if incoming.instance_of?(Array)
69
+ obj, options = incoming
70
+ elsif incoming.instance_of?(Hash)
71
+ obj = @clazz.new(model_params)
72
+ options = incoming
73
+ else
74
+ obj = incoming
75
+ end
76
+ else
77
+ obj = @clazz.new(model_params)
78
+ end
79
+
69
80
  if obj.save
70
- render json: {success: true, data: serialize(obj)}, status: :created
81
+ result = {
82
+ success: true,
83
+ data: options.key?(:fields) ? serialize(obj, include: options[:fields]) : serialize(obj)
84
+ }
85
+ render json: result, status: :created
71
86
  else
72
87
  render json: {success: false, error: obj.errors.full_messages[0]}, status: :unprocessable_entity
73
88
  end
@@ -76,13 +91,28 @@ module Comee
76
91
  end
77
92
 
78
93
  def update
79
- obj = if block_given?
80
- yield
81
- else
82
- obj = @obj
83
- end
94
+ obj = nil
95
+ options = {}
96
+ if block_given?
97
+ incoming = yield
98
+ if incoming.instance_of?(Array)
99
+ obj, options = incoming
100
+ elsif incoming.instance_of?(Hash)
101
+ obj = set_object
102
+ options = incoming
103
+ else
104
+ obj = incoming
105
+ end
106
+ else
107
+ obj = set_object
108
+ end
109
+
84
110
  if obj.update(model_params)
85
- render json: {success: true, data: serialize(obj)}
111
+ result = {
112
+ success: true,
113
+ data: options.key?(:fields) ? serialize(obj, include: options[:fields]) : serialize(obj)
114
+ }
115
+ render json: result
86
116
  else
87
117
  render json: {success: false, error: obj.errors.full_messages[0]}, status: :unprocessable_entity
88
118
  end
data/config/routes.rb CHANGED
@@ -114,6 +114,7 @@ Comee::Core::Engine.routes.draw do
114
114
  member do
115
115
  post "suggest", controller: :sales_order_items, action: :suggest_values
116
116
  post "cancel"
117
+ post "activate"
117
118
  end
118
119
  end
119
120
  resources :shipment_items do
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.2.16".freeze
3
+ VERSION = "0.2.18".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers