comee_core 0.2.16 → 0.2.17

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: 15f8ce85838c3713a94a2c4688915f6039299a372f99d7df0e878628be575051
4
+ data.tar.gz: 63850128d1d2b4f5342ccf7392d0b39298358ea400fdaadcc5b48a956cf8ffb1
5
5
  SHA512:
6
- metadata.gz: 9d77f8b9c8ab3e2dcf258faf3312a7f44698f608a7c59a7a024c3a361261b348f17c1868f7685579ffef5db0d63c1a76e95b2d81f8f1eca4c3cd2ef7216bbd37
7
- data.tar.gz: c0ac3ee94586168c23566ca9ef133c4b092d66cf6ac764d152e1a5c8fb37f4ae051db50eaa4ab14f42efb7a4bb0198648a4e6d6a99c2f9fb60ce785f2f2b02c6
6
+ metadata.gz: f5966fd4cb4dd0476c78d93c3a3fe27dd446bf6e85e64f206c96e5fd0fd8dd8d98c17589111bd199cb5b78ec87af2a273d9818f623110cc4e5fd902e4ed458ac
7
+ data.tar.gz: b2959c7cc9e0f43d18350054c439eb6a0c21b16ae303b2fd34b0fa0016bd1b2cbec61ae25399fd57e531d93ee36f1e5b91fd05e453665095fabe558e15bdec98
@@ -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}
@@ -29,7 +29,7 @@ module Comee
29
29
  :client,
30
30
  sales_order_items: :unit
31
31
  ).ransack(params[:q]).result
32
- render_content(data)
32
+ render_content(data, fields: ["client", "customer_order", "sales_order_items.product", "sales_order_items.unit"])
33
33
  end
34
34
 
35
35
  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.17".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.17
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-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers