pattana 0.1.6 → 0.1.7

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/controllers/pattana/cities_controller.rb +66 -2
  4. data/app/controllers/pattana/countries_controller.rb +79 -1
  5. data/app/controllers/pattana/regions_controller.rb +76 -2
  6. data/app/models/city.rb +21 -2
  7. data/app/models/country.rb +13 -3
  8. data/app/models/region.rb +13 -3
  9. data/app/views/pattana/cities/_form.html.erb +33 -0
  10. data/app/views/pattana/cities/_index.html.erb +18 -10
  11. data/app/views/pattana/cities/_row.html.erb +21 -44
  12. data/app/views/pattana/cities/_show.html.erb +27 -13
  13. data/app/views/pattana/countries/_form.html.erb +49 -0
  14. data/app/views/pattana/countries/_index.html.erb +24 -14
  15. data/app/views/pattana/countries/_row.html.erb +36 -55
  16. data/app/views/pattana/countries/_show.html.erb +97 -5
  17. data/app/views/pattana/countries/cities.js.erb +11 -0
  18. data/app/views/pattana/country_cities/_index.html.erb +44 -0
  19. data/app/views/pattana/country_cities/_row.html.erb +17 -0
  20. data/app/views/pattana/country_regions/_index.html.erb +3 -1
  21. data/app/views/pattana/country_regions/_row.html.erb +6 -8
  22. data/app/views/pattana/region_cities/_index.html.erb +42 -0
  23. data/app/views/pattana/region_cities/_row.html.erb +19 -0
  24. data/app/views/pattana/regions/_form.html.erb +31 -0
  25. data/app/views/pattana/regions/_index.html.erb +23 -12
  26. data/app/views/pattana/regions/_row.html.erb +27 -44
  27. data/app/views/pattana/regions/_show.html.erb +102 -19
  28. data/app/views/pattana/regions/cities.js.erb +11 -0
  29. data/config/locales/pattana/general.ar.yml +40 -0
  30. data/config/locales/pattana/general.en.yml +40 -0
  31. data/config/routes.rb +23 -2
  32. data/lib/pattana/factories.rb +1 -1
  33. data/lib/pattana/version.rb +1 -1
  34. data/spec/dummy/spec/factories/city.rb +1 -0
  35. data/spec/dummy/spec/factories/country.rb +1 -0
  36. data/spec/dummy/spec/factories/region.rb +1 -0
  37. metadata +15 -4
@@ -1,55 +1,38 @@
1
- <% edit_link = edit_admin_region_path(id: region.id) %>
2
- <% delete_link = admin_region_path(id: region.id) %>
1
+ <% edit_link = edit_region_path(id: region.id) %>
2
+ <% delete_link = region_path(id: region.id) %>
3
3
 
4
4
  <tr id="tr_region_<%= region.id %>">
5
-
6
- <td class="region-image">
7
- <%= link_to(admin_region_path(region), remote: true) do %>
8
- <%= display_image(region, "region_image.image.small.url", width: "32", height: "auto", class: "img-rectangle", alt: region.display_name) %>
5
+
6
+ <td class="region-id text-align-center"><%= region.id %></td>
7
+
8
+ <td class="region-name text-align-left"><%= link_to region.name, pattana.region_path(region), remote: true %></td>
9
+
10
+ <td class="region-name text-align-left"><%= link_to region.country.name, "#" %></td>
11
+
12
+ <td class="region-name text-align-center"><%= region.priority %></td>
13
+
14
+ <td class="region-name text-align-center"><%= region.display_show_in_api %></td>
15
+
16
+ <td class="region-name text-align-center"><%= region.display_operational %></td>
17
+
18
+ <td class="action-links text-align-center" style="width:10%">
19
+ <% if region.show_in_api? %>
20
+ <%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Hide in API"), hide_in_api_region_path(:id =>region.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
21
+ <% else %>
22
+ <%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Show in API"), show_in_api_region_path(:id =>region.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
9
23
  <% end %>
10
- </td>
11
-
12
- <td class="region-name"><%= link_to region.name, admin_region_path(region), remote: true %></td>
13
24
 
14
- <td>
15
- <% if region.unpublished? %>
16
- <span class="ml-5 mt-5 label label-default">Un-Published</span>
17
- <% elsif region.published? %>
18
- <span class="ml-5 mt-5 label label-success">Published</span>
19
- <% elsif region.disabled? %>
20
- <span class="ml-5 mt-5 label label-danger">Disabled</span>
25
+ <% if region.operational? %>
26
+ <%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Remove Operational"), remove_operational_region_path(:id =>region.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
27
+ <% else %>
28
+ <%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Mark as Operational"), mark_as_operational_region_path(:id =>region.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
21
29
  <% end %>
22
30
  </td>
23
31
 
24
- <td class="action-links" style="width:10%">
25
-
26
- <% case region.status %>
27
- <% when "published" %>
28
- <!-- Un-Publish -->
29
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_admin_region_path(:id =>region.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"region_status" %>
30
-
31
- <!-- Disable -->
32
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_admin_region_path(:id =>region.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"region_status" %>
33
- <% when "unpublished" %>
34
- <!-- Approve -->
35
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_admin_region_path(:id =>region.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"region_status" %>
36
- <!-- Disable -->
37
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_admin_region_path(:id =>region.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"region_status" %>
38
- <% when "disabled" %>
39
- <!-- Un-Publish -->
40
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_admin_region_path(:id =>region.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"region_status" %>
41
- <!-- Approve -->
42
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_admin_region_path(:id =>region.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"region_status" %>
43
- <% end %>
44
-
45
- </td>
46
-
47
- <td class="action-links" style="width:10%">
48
-
49
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit Region"), edit_link, :remote=>true, class: "edit" %>
50
-
51
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" %>
32
+ <td class="action-links text-align-center" style="width:10%">
33
+ <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit"), edit_link, :remote=>true, style: "text-align:left;", class: "edit" %>
52
34
 
35
+ <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete mt-10", style: "text-align:left;" %>
53
36
  </td>
54
37
 
55
38
  </tr>
@@ -12,6 +12,18 @@
12
12
 
13
13
  <%= theme_panel_sub_heading(@region.country.name, "#") if @region.country %><br>
14
14
 
15
+ <% if @region.show_in_api? %>
16
+ <div class="label label-success">Show In API</div>
17
+ <% else %>
18
+ <div class="label label-danger">Hide In API</div>
19
+ <% end %>
20
+
21
+ <% if @region.operational? %>
22
+ <div class="label label-success">Operational</div>
23
+ <% else %>
24
+ <div class="label label-danger">Non Operational</div>
25
+ <% end %>
26
+
15
27
  <%= clear_tag(10) %>
16
28
 
17
29
  </div>
@@ -30,11 +42,12 @@
30
42
  </li>
31
43
 
32
44
  <li class="">
33
- <a href="#technical_details" data-toggle="tab" aria-expanded="false">
45
+ <a href="#cities" data-toggle="tab" aria-expanded="false">
34
46
  <span class="visible-xs"><i class="fa-database"></i></span>
35
- <span class="hidden-xs">Technical Details</span>
47
+ <span class="hidden-xs">Cities</span>
36
48
  </a>
37
49
  </li>
50
+
38
51
  </ul>
39
52
 
40
53
  <div class="tab-content">
@@ -51,39 +64,109 @@
51
64
  <th>ID</th><td><%= @region.id %></td>
52
65
  <th>Name</th><td><%= @region.name %></td>
53
66
  </tr>
67
+
54
68
  <tr>
55
69
  <th>ISO Code</th><td><%= @region.iso_code if @region.iso_code %></td>
56
- <th>Country</th><td><%= @region.country.name if @region.country %></td>
70
+ <th>Country</th><td><%= @region.country.name if @region.country %> (<%= @region.country.try(:id) %>)</td>
57
71
  </tr>
58
- </tbody>
59
- </table>
60
- </div>
61
-
62
- </div>
63
72
 
64
- <div class="tab-pane" id="technical_details">
65
-
66
- <%= clear_tag(20) %>
67
-
68
- <div class="table-responsive">
69
- <table class="table table-striped table-condensed table-bordered mb-30">
70
- <tbody>
71
-
72
73
  <tr>
73
- <th>ID</th><td><%= @region.id %></td>
74
- <th></th><td></td>
74
+ <th>Latitude</th><td><%= @region.latitude %></td>
75
+ <th>Longitude</th><td><%= @region.longitude %></td>
75
76
  </tr>
76
77
 
77
78
  <tr>
78
79
  <th>Created At</th><td><%= @region.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @region.created_at %></td>
79
80
  <th>Updated At</th><td><%= @region.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @region.updated_at %></td>
80
81
  </tr>
81
-
82
82
  </tbody>
83
83
  </table>
84
84
  </div>
85
85
  </div>
86
86
 
87
+ <div class="tab-pane" id="cities" style="border: 1px solid #000;min-height:200px;padding:20px;margin-bottom:20px;max-height: 400px;overflow-y: auto;">
88
+ <%= clear_tag(20) %>
89
+
90
+ <div id="div_city_action_buttons">
91
+ <div class="row">
92
+ <div class="col-md-6">
93
+
94
+ <%= theme_button('Refresh', 'refresh', cities_region_path(@region), classes: "pull-left", btn_type: "white") %>
95
+
96
+ </div>
97
+ <div class="col-md-6">
98
+ <%= search_form_kuppayam(City, cities_region_path(@region), text: "") %>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ <%= clear_tag(10) %>
103
+
104
+ <div id="div_city_counts">
105
+ <div class="row">
106
+
107
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
108
+
109
+ <div style="border: 1px solid #ddd; margin-bottom: 20px;">
110
+
111
+ <div class="xe-widget xe-counter xe-counter-info"
112
+ data-count=".num"
113
+ data-from="0"
114
+ data-to="99.9"
115
+ data-suffix="%"
116
+ data-duration="2"
117
+ style="margin-bottom: 0px;
118
+ padding: 0px;
119
+ width: 15%;
120
+ margin: 0px auto;">
121
+ <div class="xe-icon">
122
+ <i class="linecons-database"></i>
123
+ </div>
124
+ <div class="xe-label">
125
+ <strong class="num"><%= @region.cities.count %></strong>
126
+ <span>Total</span>
127
+ </div>
128
+ </div>
129
+
130
+ </div>
131
+
132
+ </div>
133
+
134
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
135
+
136
+ <div style="border: 1px solid #ddd; margin-bottom: 20px;">
137
+
138
+ <div class="xe-widget xe-counter"
139
+ data-count=".num"
140
+ data-from="0"
141
+ data-to="99.9"
142
+ data-suffix="%"
143
+ data-duration="2"
144
+ style="margin-bottom: 0px;
145
+ padding: 0px;
146
+ width: 15%;
147
+ margin: 0px auto;">
148
+ <div class="xe-icon">
149
+ <i class="linecons-cloud"></i>
150
+ </div>
151
+ <div class="xe-label">
152
+ <strong class="num"><%= @region.cities.show_in_api.count %></strong>
153
+ <span>Show in API</span>
154
+ </div>
155
+ </div>
156
+
157
+ </div>
158
+
159
+ </div>
160
+
161
+
162
+ </div>
163
+ </div>
164
+ <div id="div_city_index">
165
+ <%= link_to 'Refresh', cities_region_path(@region), remote: true %>
166
+ <%#= render :partial=>"master_data/admin_cities/index" %>
167
+ </div>
168
+ </div>
169
+
87
170
  </div>
88
171
 
89
172
  <%= link_to "Close", "#", onclick: "closeLargeModal();", class: "btn btn-primary pull-right" %>
@@ -0,0 +1,11 @@
1
+ <% if @cities.any? %>
2
+
3
+ // Refresh the list
4
+ $('#div_city_index').html("<%= escape_javascript(render(:partial=>"pattana/region_cities/index")) %>");
5
+
6
+ <% else %>
7
+
8
+ var noResultsText = "<%= escape_javascript(theme_panel_message(I18n.translate('success.no_results_found')))%>";
9
+ $('#div_city_index').html(noResultsText);
10
+
11
+ <% end %>
@@ -0,0 +1,40 @@
1
+ ar:
2
+ countries:
3
+ show_in_api:
4
+ heading: "Show in API"
5
+ message: "Country will now show in API from now"
6
+ hide_in_api:
7
+ heading: "Hide in API"
8
+ message: "Country will now not show in API from now"
9
+ marked_as_operational:
10
+ heading: "Marked as Operational"
11
+ message: "Country was marked as operational successfully"
12
+ removed_operational:
13
+ heading: "Removed Operational"
14
+ message: "Country was removed from operation successfully"
15
+ regions:
16
+ show_in_api:
17
+ heading: "Show in API"
18
+ message: "Region will now show in API from now"
19
+ hide_in_api:
20
+ heading: "Hide in API"
21
+ message: "Region will now not show in API from now"
22
+ marked_as_operational:
23
+ heading: "Marked as Operational"
24
+ message: "Region was marked as operational successfully"
25
+ removed_operational:
26
+ heading: "Removed Operational"
27
+ message: "Region was removed from operation successfully"
28
+ cities:
29
+ show_in_api:
30
+ heading: "Show in API"
31
+ message: "City will now show in API from now"
32
+ hide_in_api:
33
+ heading: "Hide in API"
34
+ message: "City will now not show in API from now"
35
+ marked_as_operational:
36
+ heading: "Marked as Operational"
37
+ message: "City was marked as operational successfully"
38
+ removed_operational:
39
+ heading: "Removed Operational"
40
+ message: "City was removed from operation successfully"
@@ -0,0 +1,40 @@
1
+ en:
2
+ countries:
3
+ show_in_api:
4
+ heading: "Show in API"
5
+ message: "Country will now show in API from now"
6
+ hide_in_api:
7
+ heading: "Hide in API"
8
+ message: "Country will now not show in API from now"
9
+ marked_as_operational:
10
+ heading: "Marked as Operational"
11
+ message: "Country was marked as operational successfully"
12
+ removed_operational:
13
+ heading: "Removed Operational"
14
+ message: "Country was removed from operation successfully"
15
+ regions:
16
+ show_in_api:
17
+ heading: "Show in API"
18
+ message: "Region will now show in API from now"
19
+ hide_in_api:
20
+ heading: "Hide in API"
21
+ message: "Region will now not show in API from now"
22
+ marked_as_operational:
23
+ heading: "Marked as Operational"
24
+ message: "Region was marked as operational successfully"
25
+ removed_operational:
26
+ heading: "Removed Operational"
27
+ message: "Region was removed from operation successfully"
28
+ cities:
29
+ show_in_api:
30
+ heading: "Show in API"
31
+ message: "City will now show in API from now"
32
+ hide_in_api:
33
+ heading: "Hide in API"
34
+ message: "City will now not show in API from now"
35
+ marked_as_operational:
36
+ heading: "Marked as Operational"
37
+ message: "City was marked as operational successfully"
38
+ removed_operational:
39
+ heading: "Removed Operational"
40
+ message: "City was removed from operation successfully"
data/config/routes.rb CHANGED
@@ -6,11 +6,32 @@ Pattana::Engine.routes.draw do
6
6
  resources :countries, as: :countries do
7
7
  member do
8
8
  get :regions
9
+ get :cities
10
+ get :show_in_api
11
+ get :hide_in_api
12
+ get :mark_as_operational
13
+ get :remove_operational
9
14
  end
10
15
  end
11
16
 
12
- resources :regions, as: :regions
13
- resources :cities, as: :cities
17
+ resources :regions, as: :regions do
18
+ member do
19
+ get :cities
20
+ get :show_in_api
21
+ get :hide_in_api
22
+ get :mark_as_operational
23
+ get :remove_operational
24
+ end
25
+ end
26
+
27
+ resources :cities, as: :cities do
28
+ member do
29
+ get :show_in_api
30
+ get :hide_in_api
31
+ get :mark_as_operational
32
+ get :remove_operational
33
+ end
34
+ end
14
35
  end
15
36
 
16
37
  namespace :api do
@@ -4,4 +4,4 @@
4
4
  # Read More: https://stackoverflow.com/questions/31700345/how-can-i-share-the-factories-that-i-have-in-a-gem-and-use-it-in-other-project
5
5
 
6
6
  GEM_PATTANA_ROOT = File.dirname(File.dirname(File.dirname(__FILE__)))
7
- Dir[File.join(GEM_PATTANA_ROOT, 'spec', 'dummy', 'spec', 'factories', '*.rb')].each { |file| require(file) }
7
+ Dir[File.join(GEM_PATTANA_ROOT, 'spec', 'dummy', 'spec', 'factories', '**','*.rb')].each { |file| require(file) }
@@ -1,3 +1,3 @@
1
1
  module Pattana
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -16,6 +16,7 @@ FactoryGirl.define do
16
16
 
17
17
  priority 1000
18
18
  show_in_api false
19
+ operational false
19
20
  end
20
21
 
21
22
  end
@@ -35,6 +35,7 @@ FactoryGirl.define do
35
35
 
36
36
  priority 1000
37
37
  show_in_api false
38
+ operational false
38
39
  end
39
40
 
40
41
 
@@ -13,6 +13,7 @@ FactoryGirl.define do
13
13
 
14
14
  priority 1000
15
15
  show_in_api false
16
+ operational false
16
17
  end
17
18
 
18
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-10 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -90,14 +90,14 @@ dependencies:
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: 0.1.10
93
+ version: 0.1.12
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: 0.1.10
100
+ version: 0.1.12
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: bcrypt
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -368,25 +368,36 @@ files:
368
368
  - app/views/pattana/api/v1/docs/countries/_pos_case_1.html.erb
369
369
  - app/views/pattana/api/v1/docs/regions/_neg_case_1.html.erb
370
370
  - app/views/pattana/api/v1/docs/regions/_pos_case_1.html.erb
371
+ - app/views/pattana/cities/_form.html.erb
371
372
  - app/views/pattana/cities/_index.html.erb
372
373
  - app/views/pattana/cities/_row.html.erb
373
374
  - app/views/pattana/cities/_show.html.erb
374
375
  - app/views/pattana/cities/index.html.erb
376
+ - app/views/pattana/countries/_form.html.erb
375
377
  - app/views/pattana/countries/_index.html.erb
376
378
  - app/views/pattana/countries/_row.html.erb
377
379
  - app/views/pattana/countries/_show.html.erb
380
+ - app/views/pattana/countries/cities.js.erb
378
381
  - app/views/pattana/countries/index.html.erb
379
382
  - app/views/pattana/countries/regions.js.erb
383
+ - app/views/pattana/country_cities/_index.html.erb
384
+ - app/views/pattana/country_cities/_row.html.erb
380
385
  - app/views/pattana/country_regions/_form.html.erb
381
386
  - app/views/pattana/country_regions/_index.html.erb
382
387
  - app/views/pattana/country_regions/_row.html.erb
383
388
  - app/views/pattana/dashboard/index.html.erb
389
+ - app/views/pattana/region_cities/_index.html.erb
390
+ - app/views/pattana/region_cities/_row.html.erb
391
+ - app/views/pattana/regions/_form.html.erb
384
392
  - app/views/pattana/regions/_index.html.erb
385
393
  - app/views/pattana/regions/_row.html.erb
386
394
  - app/views/pattana/regions/_show.html.erb
395
+ - app/views/pattana/regions/cities.js.erb
387
396
  - app/views/pattana/regions/index.html.erb
388
397
  - config/locales/pattana/api.ar.yml
389
398
  - config/locales/pattana/api.en.yml
399
+ - config/locales/pattana/general.ar.yml
400
+ - config/locales/pattana/general.en.yml
390
401
  - config/routes.rb
391
402
  - db/master_data/cities.sql
392
403
  - db/master_data/countries.sql