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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/controllers/pattana/cities_controller.rb +66 -2
- data/app/controllers/pattana/countries_controller.rb +79 -1
- data/app/controllers/pattana/regions_controller.rb +76 -2
- data/app/models/city.rb +21 -2
- data/app/models/country.rb +13 -3
- data/app/models/region.rb +13 -3
- data/app/views/pattana/cities/_form.html.erb +33 -0
- data/app/views/pattana/cities/_index.html.erb +18 -10
- data/app/views/pattana/cities/_row.html.erb +21 -44
- data/app/views/pattana/cities/_show.html.erb +27 -13
- data/app/views/pattana/countries/_form.html.erb +49 -0
- data/app/views/pattana/countries/_index.html.erb +24 -14
- data/app/views/pattana/countries/_row.html.erb +36 -55
- data/app/views/pattana/countries/_show.html.erb +97 -5
- data/app/views/pattana/countries/cities.js.erb +11 -0
- data/app/views/pattana/country_cities/_index.html.erb +44 -0
- data/app/views/pattana/country_cities/_row.html.erb +17 -0
- data/app/views/pattana/country_regions/_index.html.erb +3 -1
- data/app/views/pattana/country_regions/_row.html.erb +6 -8
- data/app/views/pattana/region_cities/_index.html.erb +42 -0
- data/app/views/pattana/region_cities/_row.html.erb +19 -0
- data/app/views/pattana/regions/_form.html.erb +31 -0
- data/app/views/pattana/regions/_index.html.erb +23 -12
- data/app/views/pattana/regions/_row.html.erb +27 -44
- data/app/views/pattana/regions/_show.html.erb +102 -19
- data/app/views/pattana/regions/cities.js.erb +11 -0
- data/config/locales/pattana/general.ar.yml +40 -0
- data/config/locales/pattana/general.en.yml +40 -0
- data/config/routes.rb +23 -2
- data/lib/pattana/factories.rb +1 -1
- data/lib/pattana/version.rb +1 -1
- data/spec/dummy/spec/factories/city.rb +1 -0
- data/spec/dummy/spec/factories/country.rb +1 -0
- data/spec/dummy/spec/factories/region.rb +1 -0
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 759605f6662a7551093ef0a53623c7e6c4dd58ea
|
4
|
+
data.tar.gz: 57236bd2235c8279a2cbb13a13dd73fa7c3dc553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0527e845479cd559de18d78baf7045f75f48ef76a5d9810337d9d4f9ca4fe6553df5635916dee5930a98a95e6a288c88ebd89af555a2a9945b6840950d79290d
|
7
|
+
data.tar.gz: 55fc7ceee1a7196084326f29ec11b93381ae8456a3ff6bbb631a43c576ffaaaefd368722212859bca4b74abf46dd74c949961129a30f81c0951334f89432506e
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
|
@@ -1,10 +1,74 @@
|
|
1
1
|
module Pattana
|
2
2
|
class CitiesController < ResourceController
|
3
3
|
|
4
|
+
def show_in_api
|
5
|
+
@city = @r_object = City.find(params[:id])
|
6
|
+
if @city
|
7
|
+
@city.show_in_api = true
|
8
|
+
if @city.valid?
|
9
|
+
@city.save
|
10
|
+
set_notification(true, I18n.t('cities.show_in_api.heading'), I18n.t('cities.show_in_api.message'))
|
11
|
+
else
|
12
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @city.errors.full_messages.join("<br>"))
|
13
|
+
end
|
14
|
+
else
|
15
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
16
|
+
end
|
17
|
+
render_row
|
18
|
+
end
|
19
|
+
|
20
|
+
def hide_in_api
|
21
|
+
@city = @r_object = City.find(params[:id])
|
22
|
+
if @city
|
23
|
+
@city.show_in_api = false
|
24
|
+
if @city.valid?
|
25
|
+
@city.save
|
26
|
+
set_notification(true, I18n.t('cities.hide_in_api.heading'), I18n.t('cities.hide_in_api.message'))
|
27
|
+
else
|
28
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @city.errors.full_messages.join("<br>"))
|
29
|
+
end
|
30
|
+
else
|
31
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
32
|
+
end
|
33
|
+
render_row
|
34
|
+
end
|
35
|
+
|
36
|
+
def mark_as_operational
|
37
|
+
@city = @r_object = City.find(params[:id])
|
38
|
+
if @city
|
39
|
+
@city.operational = true
|
40
|
+
if @city.valid?
|
41
|
+
@city.save
|
42
|
+
set_notification(true, I18n.t('cities.marked_as_operational.heading'), I18n.t('cities.marked_as_operational.message'))
|
43
|
+
else
|
44
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @city.errors.full_messages.join("<br>"))
|
45
|
+
end
|
46
|
+
else
|
47
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
48
|
+
end
|
49
|
+
render_row
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_operational
|
53
|
+
@city = @r_object = City.find(params[:id])
|
54
|
+
if @city
|
55
|
+
@city.operational = false
|
56
|
+
if @city.valid?
|
57
|
+
@city.save
|
58
|
+
set_notification(true, I18n.t('cities.removed_operational.heading'), I18n.t('cities.removed_operational.message'))
|
59
|
+
else
|
60
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @city.errors.full_messages.join("<br>"))
|
61
|
+
end
|
62
|
+
else
|
63
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
64
|
+
end
|
65
|
+
render_row
|
66
|
+
end
|
67
|
+
|
4
68
|
private
|
5
69
|
|
6
70
|
def get_collections
|
7
|
-
@relation = City.where("")
|
71
|
+
@relation = City.includes(:country, :region).where("")
|
8
72
|
|
9
73
|
parse_filters
|
10
74
|
apply_filters
|
@@ -57,7 +121,7 @@ module Pattana
|
|
57
121
|
end
|
58
122
|
|
59
123
|
def permitted_params
|
60
|
-
params.require(:city).permit(:name)
|
124
|
+
params.require(:city).permit(:name, :alternative_names, :iso_code, :population, :latitude, :longitude, :country_id, :region_id)
|
61
125
|
end
|
62
126
|
|
63
127
|
def set_navs
|
@@ -11,6 +11,80 @@ module Pattana
|
|
11
11
|
@regions = @relation.page(@current_page).per(@per_page)
|
12
12
|
end
|
13
13
|
|
14
|
+
def cities
|
15
|
+
@country = Country.find_by_id(params[:id])
|
16
|
+
@relation = @country.cities.limit(50)
|
17
|
+
|
18
|
+
parse_filters
|
19
|
+
apply_filters
|
20
|
+
|
21
|
+
@cities = @relation.page(@current_page).per(@per_page)
|
22
|
+
end
|
23
|
+
|
24
|
+
def show_in_api
|
25
|
+
@country = @r_object = Country.find(params[:id])
|
26
|
+
if @country
|
27
|
+
@country.show_in_api = true
|
28
|
+
if @country.valid?
|
29
|
+
@country.save
|
30
|
+
set_notification(true, I18n.t('countries.show_in_api.heading'), I18n.t('countries.show_in_api.message'))
|
31
|
+
else
|
32
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors.full_messages.join("<br>"))
|
33
|
+
end
|
34
|
+
else
|
35
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
36
|
+
end
|
37
|
+
render_row
|
38
|
+
end
|
39
|
+
|
40
|
+
def hide_in_api
|
41
|
+
@country = @r_object = Country.find(params[:id])
|
42
|
+
if @country
|
43
|
+
@country.show_in_api = false
|
44
|
+
if @country.valid?
|
45
|
+
@country.save
|
46
|
+
set_notification(true, I18n.t('countries.hide_in_api.heading'), I18n.t('countries.hide_in_api.message'))
|
47
|
+
else
|
48
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors.full_messages.join("<br>"))
|
49
|
+
end
|
50
|
+
else
|
51
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
52
|
+
end
|
53
|
+
render_row
|
54
|
+
end
|
55
|
+
|
56
|
+
def mark_as_operational
|
57
|
+
@country = @r_object = Country.find(params[:id])
|
58
|
+
if @country
|
59
|
+
@country.operational = true
|
60
|
+
if @country.valid?
|
61
|
+
@country.save
|
62
|
+
set_notification(true, I18n.t('countries.marked_as_operational.heading'), I18n.t('countries.marked_as_operational.message'))
|
63
|
+
else
|
64
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors.full_messages.join("<br>"))
|
65
|
+
end
|
66
|
+
else
|
67
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
68
|
+
end
|
69
|
+
render_row
|
70
|
+
end
|
71
|
+
|
72
|
+
def remove_operational
|
73
|
+
@country = @r_object = Country.find(params[:id])
|
74
|
+
if @country
|
75
|
+
@country.operational = false
|
76
|
+
if @country.valid?
|
77
|
+
@country.save
|
78
|
+
set_notification(true, I18n.t('countries.removed_operational.heading'), I18n.t('countries.removed_operational.message'))
|
79
|
+
else
|
80
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @country.errors.full_messages.join("<br>"))
|
81
|
+
end
|
82
|
+
else
|
83
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
84
|
+
end
|
85
|
+
render_row
|
86
|
+
end
|
87
|
+
|
14
88
|
private
|
15
89
|
|
16
90
|
def get_collections
|
@@ -65,7 +139,11 @@ module Pattana
|
|
65
139
|
end
|
66
140
|
|
67
141
|
def permitted_params
|
68
|
-
params.require(:country).permit(:name
|
142
|
+
params.require(:country).permit(:name, :official_name, :iso_name,
|
143
|
+
:fips, :iso_alpha_2, :iso_alpha_3,
|
144
|
+
:itu_code, :dialing_prefix, :tld,
|
145
|
+
:latitude, :longitude, :capital,
|
146
|
+
:priority, :languages)
|
69
147
|
end
|
70
148
|
|
71
149
|
def set_navs
|
@@ -1,10 +1,84 @@
|
|
1
1
|
module Pattana
|
2
2
|
class RegionsController < ResourceController
|
3
3
|
|
4
|
+
def cities
|
5
|
+
@region = Region.find_by_id(params[:id])
|
6
|
+
@relation = @region.cities.limit(50)
|
7
|
+
|
8
|
+
parse_filters
|
9
|
+
apply_filters
|
10
|
+
|
11
|
+
@cities = @relation.page(@current_page).per(@per_page)
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_in_api
|
15
|
+
@region = @r_object = Region.find(params[:id])
|
16
|
+
if @region
|
17
|
+
@region.show_in_api = true
|
18
|
+
if @region.valid?
|
19
|
+
@region.save
|
20
|
+
set_notification(true, I18n.t('regions.show_in_api.heading'), I18n.t('regions.show_in_api.message'))
|
21
|
+
else
|
22
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors.full_messages.join("<br>"))
|
23
|
+
end
|
24
|
+
else
|
25
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
26
|
+
end
|
27
|
+
render_row
|
28
|
+
end
|
29
|
+
|
30
|
+
def hide_in_api
|
31
|
+
@region = @r_object = Region.find(params[:id])
|
32
|
+
if @region
|
33
|
+
@region.show_in_api = false
|
34
|
+
if @region.valid?
|
35
|
+
@region.save
|
36
|
+
set_notification(true, I18n.t('regions.hide_in_api.heading'), I18n.t('regions.hide_in_api.message'))
|
37
|
+
else
|
38
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors.full_messages.join("<br>"))
|
39
|
+
end
|
40
|
+
else
|
41
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
42
|
+
end
|
43
|
+
render_row
|
44
|
+
end
|
45
|
+
|
46
|
+
def mark_as_operational
|
47
|
+
@region = @r_object = Region.find(params[:id])
|
48
|
+
if @region
|
49
|
+
@region.operational = true
|
50
|
+
if @region.valid?
|
51
|
+
@region.save
|
52
|
+
set_notification(true, I18n.t('regions.marked_as_operational.heading'), I18n.t('regions.marked_as_operational.message'))
|
53
|
+
else
|
54
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors.full_messages.join("<br>"))
|
55
|
+
end
|
56
|
+
else
|
57
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
58
|
+
end
|
59
|
+
render_row
|
60
|
+
end
|
61
|
+
|
62
|
+
def remove_operational
|
63
|
+
@region = @r_object = Region.find(params[:id])
|
64
|
+
if @region
|
65
|
+
@region.operational = false
|
66
|
+
if @region.valid?
|
67
|
+
@region.save
|
68
|
+
set_notification(true, I18n.t('regions.removed_operational.heading'), I18n.t('regions.removed_operational.message'))
|
69
|
+
else
|
70
|
+
set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors.full_messages.join("<br>"))
|
71
|
+
end
|
72
|
+
else
|
73
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize))
|
74
|
+
end
|
75
|
+
render_row
|
76
|
+
end
|
77
|
+
|
4
78
|
private
|
5
79
|
|
6
80
|
def get_collections
|
7
|
-
@relation = Region.where("")
|
81
|
+
@relation = Region.includes(:country).where("")
|
8
82
|
|
9
83
|
parse_filters
|
10
84
|
apply_filters
|
@@ -55,7 +129,7 @@ module Pattana
|
|
55
129
|
end
|
56
130
|
|
57
131
|
def permitted_params
|
58
|
-
params.require(:region).permit(:name)
|
132
|
+
params.require(:region).permit(:name, :iso_code, :latitude, :longitude, :country_id)
|
59
133
|
end
|
60
134
|
|
61
135
|
def set_navs
|
data/app/models/city.rb
CHANGED
@@ -10,6 +10,9 @@ class City < Pattana::ApplicationRecord
|
|
10
10
|
# Validations
|
11
11
|
validates :name, presence: true, length: {minimum: 3, maximum: 128}
|
12
12
|
|
13
|
+
# Callbacks
|
14
|
+
before_validation :set_country, on: :create
|
15
|
+
|
13
16
|
# ------------------
|
14
17
|
# Class Methods
|
15
18
|
# ------------------
|
@@ -124,15 +127,23 @@ class City < Pattana::ApplicationRecord
|
|
124
127
|
# Instance Methods
|
125
128
|
# ------------------
|
126
129
|
|
130
|
+
# Callback Methods
|
131
|
+
# ------------------
|
132
|
+
|
133
|
+
def set_country
|
134
|
+
self.country = self.region.country if self.region && self.region.country
|
135
|
+
end
|
136
|
+
|
127
137
|
# Permission Methods
|
128
138
|
# ------------------
|
129
139
|
|
130
140
|
def can_be_edited?
|
131
|
-
|
141
|
+
true
|
132
142
|
end
|
133
143
|
|
134
144
|
def can_be_deleted?
|
135
|
-
false
|
145
|
+
return false if operational?
|
146
|
+
true
|
136
147
|
end
|
137
148
|
|
138
149
|
# Other Methods
|
@@ -153,5 +164,13 @@ class City < Pattana::ApplicationRecord
|
|
153
164
|
def display_show_in_api
|
154
165
|
self.show_in_api ? "Yes" : "No"
|
155
166
|
end
|
167
|
+
|
168
|
+
# * Return Yes or No
|
169
|
+
# == Examples
|
170
|
+
# >>> city.display_operational
|
171
|
+
# => "Yes"
|
172
|
+
def display_operational
|
173
|
+
self.operational ? "Yes" : "No"
|
174
|
+
end
|
156
175
|
|
157
176
|
end
|
data/app/models/country.rb
CHANGED
@@ -99,11 +99,13 @@ class Country < Pattana::ApplicationRecord
|
|
99
99
|
# ------------------
|
100
100
|
|
101
101
|
def can_be_edited?
|
102
|
-
|
102
|
+
true
|
103
103
|
end
|
104
104
|
|
105
105
|
def can_be_deleted?
|
106
|
-
false
|
106
|
+
return false if self.regions.any? || self.cities.any?
|
107
|
+
return false if operational?
|
108
|
+
true
|
107
109
|
end
|
108
110
|
|
109
111
|
# Other Methods
|
@@ -120,9 +122,17 @@ class Country < Pattana::ApplicationRecord
|
|
120
122
|
# * Return Yes or No
|
121
123
|
# == Examples
|
122
124
|
# >>> country.display_show_in_api
|
123
|
-
# => "
|
125
|
+
# => "No"
|
124
126
|
def display_show_in_api
|
125
127
|
self.show_in_api ? "Yes" : "No"
|
126
128
|
end
|
129
|
+
|
130
|
+
# * Return Yes or No
|
131
|
+
# == Examples
|
132
|
+
# >>> country.display_operational
|
133
|
+
# => "Yes"
|
134
|
+
def display_operational
|
135
|
+
self.operational ? "Yes" : "No"
|
136
|
+
end
|
127
137
|
|
128
138
|
end
|
data/app/models/region.rb
CHANGED
@@ -86,11 +86,13 @@ class Region < Pattana::ApplicationRecord
|
|
86
86
|
# ------------------
|
87
87
|
|
88
88
|
def can_be_edited?
|
89
|
-
|
89
|
+
true
|
90
90
|
end
|
91
91
|
|
92
92
|
def can_be_deleted?
|
93
|
-
false
|
93
|
+
return false if self.cities.any?
|
94
|
+
return false if operational?
|
95
|
+
true
|
94
96
|
end
|
95
97
|
|
96
98
|
# Other Methods
|
@@ -107,9 +109,17 @@ class Region < Pattana::ApplicationRecord
|
|
107
109
|
# * Return Yes or No
|
108
110
|
# == Examples
|
109
111
|
# >>> region.display_show_in_api
|
110
|
-
# => "
|
112
|
+
# => "No"
|
111
113
|
def display_show_in_api
|
112
114
|
self.show_in_api ? "Yes" : "No"
|
113
115
|
end
|
116
|
+
|
117
|
+
# * Return Yes or No
|
118
|
+
# == Examples
|
119
|
+
# >>> region.display_operational
|
120
|
+
# => "Yes"
|
121
|
+
def display_operational
|
122
|
+
self.operational ? "Yes" : "No"
|
123
|
+
end
|
114
124
|
|
115
125
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= form_for(@city, :html => {:id=>"form_city", :class=>"mb-0 form-horizontal", :role => "form", :method => (@city.new_record? ? :post : :put), :remote=>true}) do |f| %>
|
2
|
+
|
3
|
+
<div id="city_form_error">
|
4
|
+
<%= @city.errors[:base].to_sentence %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="row">
|
8
|
+
<div class="col-md-12 col-sm-12">
|
9
|
+
<div class="form-inputs mb-30 mt-30">
|
10
|
+
|
11
|
+
<%= theme_form_field(@city, :name) %>
|
12
|
+
<%= theme_form_field(@city, :alternative_names) %>
|
13
|
+
|
14
|
+
<%= theme_form_field(@city, :iso_code, required: false) %>
|
15
|
+
<%= theme_form_field(@city, :population, required: false) %>
|
16
|
+
|
17
|
+
<%= theme_form_field(@city, :latitude, required: false) %>
|
18
|
+
<%= theme_form_field(@city, :longitude, required: false) %>
|
19
|
+
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div>
|
23
|
+
|
24
|
+
<%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
|
25
|
+
|
26
|
+
<%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeLargeModal();", class: "pull-right ml-10 btn btn-white" %>
|
27
|
+
|
28
|
+
</div>
|
29
|
+
<%= clear_tag(10) %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<% end %>
|
33
|
+
|
@@ -2,22 +2,20 @@
|
|
2
2
|
<table class="table table-hover members-table middle-align">
|
3
3
|
<thead>
|
4
4
|
<tr>
|
5
|
-
<th style="text-align:center;width:
|
5
|
+
<th style="text-align:center;width:15%;">#</th>
|
6
6
|
<th style="text-align:left;width:30%;">Name</th>
|
7
7
|
<th style="text-align:center;width:15%;">Region</th>
|
8
8
|
<th style="text-align:center;width:15%;">Country</th>
|
9
9
|
<th style="text-align:center;width:10%;">Priority</th>
|
10
10
|
<th style="text-align:center;width:15%;">Show in API</th>
|
11
|
-
<th style="text-align:center;width:10%;">Actions</th>
|
11
|
+
<th style="text-align:center;width:10%;" colspan="2">Actions</th>
|
12
12
|
</tr>
|
13
13
|
</thead>
|
14
14
|
<tbody>
|
15
15
|
<% @cities.each_with_index do |city, i| %>
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
<% edit_link = "#" %>
|
20
|
-
<% delete_link = "#" %>
|
17
|
+
<% edit_link = edit_city_path(id: city.id) %>
|
18
|
+
<% delete_link = city_path(id: city.id) %>
|
21
19
|
|
22
20
|
<tr id="tr_city_<%= city.id %>">
|
23
21
|
|
@@ -29,14 +27,24 @@
|
|
29
27
|
<td class="text-align-center"><%= city.priority %></td>
|
30
28
|
<td class="text-align-center"><%= city.display_show_in_api %></td>
|
31
29
|
|
32
|
-
<td class="action-links" style="width:10%">
|
30
|
+
<td class="action-links text-align-center" style="width:10%">
|
31
|
+
<% if city.show_in_api? %>
|
32
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Hide in API"), hide_in_api_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
|
33
|
+
<% else %>
|
34
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Show in API"), show_in_api_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
|
35
|
+
<% end %>
|
33
36
|
|
37
|
+
<% if city.operational? %>
|
38
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Remove Operational"), remove_operational_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
|
39
|
+
<% else %>
|
40
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Mark as Operational"), mark_as_operational_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
|
41
|
+
<% end %>
|
42
|
+
</td>
|
43
|
+
|
44
|
+
<td class="action-links text-align-center" style="width:10%">
|
34
45
|
<%= link_to raw("<i class=\"linecons-pencil\"></i> Edit City"), edit_link, :remote=>true, class: "edit" %>
|
35
46
|
|
36
47
|
<%= 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" %>
|
37
|
-
|
38
|
-
</td>
|
39
|
-
|
40
48
|
</tr>
|
41
49
|
<% end %>
|
42
50
|
</tbody>
|
@@ -1,55 +1,32 @@
|
|
1
|
-
<% edit_link =
|
2
|
-
<% delete_link =
|
1
|
+
<% edit_link = edit_city_path(id: city.id) %>
|
2
|
+
<% delete_link = city_path(id: city.id) %>
|
3
3
|
|
4
4
|
<tr id="tr_city_<%= city.id %>">
|
5
|
-
|
6
|
-
<td class="
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<td
|
13
|
-
|
14
|
-
<td>
|
15
|
-
<% if city.
|
16
|
-
<
|
17
|
-
<%
|
18
|
-
<
|
19
|
-
<% elsif city.disabled? %>
|
20
|
-
<span class="ml-5 mt-5 label label-danger">Disabled</span>
|
5
|
+
|
6
|
+
<td class="text-align-center"><%= city.id %></td>
|
7
|
+
<td class="text-align-left"><%= link_to city.name, pattana.city_path(city), remote: true %></td>
|
8
|
+
|
9
|
+
<td class="text-align-center"><%= city.region.name if city.region %></td>
|
10
|
+
<td class="text-align-center"><%= city.country.name if city.country %></td>
|
11
|
+
<td class="text-align-center"><%= city.priority %></td>
|
12
|
+
<td class="text-align-center"><%= city.display_show_in_api %></td>
|
13
|
+
|
14
|
+
<td class="action-links text-align-center" style="width:10%">
|
15
|
+
<% if city.show_in_api? %>
|
16
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Hide in API"), hide_in_api_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
|
17
|
+
<% else %>
|
18
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Show in API"), show_in_api_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
|
21
19
|
<% end %>
|
22
|
-
</td>
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
<%
|
27
|
-
|
28
|
-
<!-- Un-Publish -->
|
29
|
-
<%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_admin_city_path(:id =>city.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"city_status" %>
|
30
|
-
|
31
|
-
<!-- Disable -->
|
32
|
-
<%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_admin_city_path(:id =>city.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"city_status" %>
|
33
|
-
<% when "unpublished" %>
|
34
|
-
<!-- Approve -->
|
35
|
-
<%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_admin_city_path(:id =>city.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"city_status" %>
|
36
|
-
<!-- Disable -->
|
37
|
-
<%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_admin_city_path(:id =>city.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"city_status" %>
|
38
|
-
<% when "disabled" %>
|
39
|
-
<!-- Un-Publish -->
|
40
|
-
<%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_admin_city_path(:id =>city.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"city_status" %>
|
41
|
-
<!-- Approve -->
|
42
|
-
<%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_admin_city_path(:id =>city.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"city_status" %>
|
21
|
+
<% if city.operational? %>
|
22
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Remove Operational"), remove_operational_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "delete" %>
|
23
|
+
<% else %>
|
24
|
+
<%= link_to raw("<i class=\"fa fa-square mr-5\"></i> Mark as Operational"), mark_as_operational_city_path(:id =>city.id), :remote=>true, role: "menuitem", tabindex: "-1", style: "text-align:left;", class: "edit" %>
|
43
25
|
<% end %>
|
44
|
-
|
45
26
|
</td>
|
46
27
|
|
47
|
-
<td class="action-links" style="width:10%">
|
48
|
-
|
28
|
+
<td class="action-links text-align-center" style="width:10%">
|
49
29
|
<%= link_to raw("<i class=\"linecons-pencil\"></i> Edit City"), edit_link, :remote=>true, class: "edit" %>
|
50
30
|
|
51
31
|
<%= 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" %>
|
52
|
-
|
53
|
-
</td>
|
54
|
-
|
55
32
|
</tr>
|
@@ -9,6 +9,18 @@
|
|
9
9
|
<%= theme_panel_heading(@city.name) %>
|
10
10
|
|
11
11
|
<%= theme_panel_sub_heading(@city.country.name, "#") if @city.country %><br>
|
12
|
+
|
13
|
+
<% if @city.show_in_api? %>
|
14
|
+
<div class="label label-success">Show In API</div>
|
15
|
+
<% else %>
|
16
|
+
<div class="label label-danger">Hide In API</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% if @city.operational? %>
|
20
|
+
<div class="label label-success">Operational</div>
|
21
|
+
<% else %>
|
22
|
+
<div class="label label-danger">Non Operational</div>
|
23
|
+
<% end %>
|
12
24
|
|
13
25
|
<%= clear_tag(10) %>
|
14
26
|
|
@@ -26,13 +38,6 @@
|
|
26
38
|
<span class="hidden-xs">City Details</span>
|
27
39
|
</a>
|
28
40
|
</li>
|
29
|
-
|
30
|
-
<li class="">
|
31
|
-
<a href="#technical_details" data-toggle="tab" aria-expanded="false">
|
32
|
-
<span class="visible-xs"><i class="fa-database"></i></span>
|
33
|
-
<span class="hidden-xs">Technical Details</span>
|
34
|
-
</a>
|
35
|
-
</li>
|
36
41
|
</ul>
|
37
42
|
|
38
43
|
<div class="tab-content">
|
@@ -49,10 +54,22 @@
|
|
49
54
|
<th>ID</th><td><%= @city.id %></td>
|
50
55
|
<th>Name</th><td><%= @city.name %></td>
|
51
56
|
</tr>
|
57
|
+
|
52
58
|
<tr>
|
53
|
-
<th>
|
54
|
-
<th
|
59
|
+
<th>Region</th><td><%= @city.region.name if @city.region %> (<%= @city.region.try(:id) %>)</td>
|
60
|
+
<th>Country</th><td><%= @city.country.name if @city.country %> (<%= @city.country.try(:id) %>)</td>
|
55
61
|
</tr>
|
62
|
+
|
63
|
+
<tr>
|
64
|
+
<th>Latitude</th><td><%= @city.latitude %></td>
|
65
|
+
<th>Longitude</th><td><%= @city.longitude %></td>
|
66
|
+
</tr>
|
67
|
+
|
68
|
+
<tr>
|
69
|
+
<th>Created At</th><td><%= @city.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @city.created_at %></td>
|
70
|
+
<th>Updated At</th><td><%= @city.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @city.updated_at %></td>
|
71
|
+
</tr>
|
72
|
+
|
56
73
|
</tbody>
|
57
74
|
</table>
|
58
75
|
</div>
|
@@ -72,10 +89,7 @@
|
|
72
89
|
<th></th><td></td>
|
73
90
|
</tr>
|
74
91
|
|
75
|
-
|
76
|
-
<th>Created At</th><td><%= @city.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @city.created_at %></td>
|
77
|
-
<th>Updated At</th><td><%= @city.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @city.updated_at %></td>
|
78
|
-
</tr>
|
92
|
+
|
79
93
|
|
80
94
|
</tbody>
|
81
95
|
</table>
|