dhatu 0.1.9 → 0.1.10

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
  SHA1:
3
- metadata.gz: 4bf01e6348dbd1e36eda6fdb715f8a0f4b263c23
4
- data.tar.gz: cd49b8e0823e61004aee6ed689f47a851caccb86
3
+ metadata.gz: b44d66d46f512e9310e9b7ee907df3e6611179f7
4
+ data.tar.gz: b785eb69e6d6d2178cb6bfcb4fa64c0b51ee1978
5
5
  SHA512:
6
- metadata.gz: b130516a2a5992a155772813047131f0e0b540a2e43d6b7e2b419979b3ac83b8ffdfece6714afbc34642cb492f600c2723b13fc06d3070181bf2b0db642426d6
7
- data.tar.gz: bef9428021bbf487d6e0291bca54e454c10d52986e33673bde70602ce44c6794cb8a822397fae8be0860864129fad0a1a2c19c9a9b741627d9c3d13c93d07cd9
6
+ metadata.gz: 76b6e80ed6f7665296fcd71553ce4857cd2f99b3cc4c23d45f0596be1587b90546156eb6bb2eae42f9a7a276d4d6e883129693052dc60d5da5b94b0389544942
7
+ data.tar.gz: ebfa076bd05c6ffecada3221aca343c93deecba065124c4ab8b87c44fc0da2883f913bd34802600d89a678002795116b18434ed72e46c1d03546dca23a728663
@@ -0,0 +1,77 @@
1
+ module Dhatu
2
+ class SectionTypesController < ResourceController
3
+
4
+ before_action :require_super_admin
5
+
6
+ private
7
+
8
+ def get_resource
9
+ @r_object = @resource_options[:class].find_by_id(params[:id])
10
+ end
11
+
12
+ def get_collections
13
+ @relation = SectionType.where("")
14
+
15
+ parse_filters
16
+ apply_filters
17
+
18
+ @section_types = @r_objects = @relation.page(@current_page).per(@per_page)
19
+
20
+ return true
21
+ end
22
+
23
+ def apply_filters
24
+ @relation = @relation.search(@query) if @query
25
+
26
+ @order_by = "created_at desc" unless @order_by
27
+ @relation = @relation.order(@order_by)
28
+ end
29
+
30
+ def configure_filter_settings
31
+ @filter_settings = {
32
+ string_filters: [
33
+ { filter_name: :query }
34
+ ],
35
+ boolean_filters: [],
36
+ reference_filters: [],
37
+ variable_filters: [],
38
+ }
39
+ end
40
+
41
+ def configure_filter_ui_settings
42
+ @filter_ui_settings = {}
43
+ end
44
+
45
+ def resource_controller_configuration
46
+ {
47
+ page_title: "Section Types",
48
+ js_view_path: "/kuppayam/workflows/parrot",
49
+ view_path: "/dhatu/section_types",
50
+ show_modal_after_create: false,
51
+ show_modal_after_update: false,
52
+ collection_name: :section_types,
53
+ item_name: :section_type,
54
+ class: Dhatu::SectionType
55
+ }
56
+ end
57
+
58
+ def breadcrumbs_configuration
59
+ {
60
+ heading: "Manage Section Types",
61
+ icon: "fa-reorder",
62
+ description: "Listing all Section Types",
63
+ links: [{name: "Home", link: breadcrumb_home_path, icon: 'fa-home'},
64
+ {name: "Manage Section Types", link: section_types_path, icon: 'fa-reorder', active: true}]
65
+ }
66
+ end
67
+
68
+ def permitted_params
69
+ params.require("dhatu/section_type").permit(:name, :code)
70
+ end
71
+
72
+ def set_navs
73
+ set_nav("dhatu/section_types")
74
+ end
75
+
76
+ end
77
+ end
@@ -4,7 +4,7 @@ module Dhatu
4
4
  private
5
5
 
6
6
  def permitted_params
7
- params.require("dhatu/section").permit(:section_type, :title, :sub_title, :short_description, :long_description, :button_one_text, :button_two_text, :button_one_link, :button_two_link, :category_id)
7
+ params.require("dhatu/section").permit(:section_type_id, :title, :sub_title, :short_description, :long_description, :button_one_text, :button_two_text, :button_one_link, :button_two_link, :category_id)
8
8
  end
9
9
 
10
10
  def get_collections
@@ -100,6 +100,10 @@ class Dhatu::Category < Dhatu::ApplicationRecord
100
100
  self.name
101
101
  end
102
102
 
103
+ def to_param
104
+ "#{id}-#{name.parameterize[0..32]}"
105
+ end
106
+
103
107
  def display_category_type
104
108
  self.category_type.try(:demodulize).try(:pluralize).try(:titleize)
105
109
  end
@@ -17,7 +17,7 @@ class Dhatu::Section < Dhatu::ApplicationRecord
17
17
  validates :button_two_link, length: {maximum: 512}, allow_blank: true
18
18
 
19
19
  # Associations
20
- belongs_to :category
20
+ belongs_to :section_type, :class_name => "Dhatu::SectionType"
21
21
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
22
22
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
23
23
 
@@ -36,10 +36,7 @@ class Dhatu::Section < Dhatu::ApplicationRecord
36
36
 
37
37
  scope :upcoming, lambda { where("created_at >= ?", Time.now) }
38
38
  scope :past, lambda { where("created_at < ?", Time.now) }
39
-
40
- def find_by_section_type(st)
41
- self.where("section_type = ?", st).published.first
42
- end
39
+ scope :find_by_section_type, lambda {|section_code| joins(:section_type).where("code = ?", section_code) }
43
40
 
44
41
  # ------------------
45
42
  # Instance variables
@@ -0,0 +1,78 @@
1
+ class Dhatu::SectionType < Dhatu::ApplicationRecord
2
+
3
+ # Set Table Name
4
+ self.table_name = "section_types"
5
+
6
+ # Validations
7
+ validates :name, presence: true, length: {minimum: 3, maximum: 64}
8
+ validates :code, presence: true, length: {minimum: 3, maximum: 64}
9
+
10
+ # ------------------
11
+ # Class Methods
12
+ # ------------------
13
+
14
+ scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%') OR\
15
+ LOWER(code) LIKE LOWER('%#{query}%')")}
16
+
17
+ scope :upcoming, lambda { where("created_at >= ?", Time.now) }
18
+ scope :past, lambda { where("created_at < ?", Time.now) }
19
+
20
+ # Associations
21
+ has_many :sections, :class_name => "Dhatu::Section"
22
+
23
+ # ------------------
24
+ # Class variables
25
+ # ------------------
26
+
27
+ def self.save_row_data(hsh)
28
+ # Initializing error hash for displaying all errors altogether
29
+ error_object = Kuppayam::Importer::ErrorHash.new
30
+
31
+ return error_object if hsh[:name].blank?
32
+
33
+ section_type = Dhatu::SectionType.find_by_name(hsh[:name]) || Dhatu::SectionType.new
34
+ section_type.name = hsh[:name]
35
+ section_type.code = hsh[:code]
36
+
37
+ if section_type.valid?
38
+ begin
39
+ section_type.save!
40
+ rescue Exception => e
41
+ summary = "uncaught #{e} exception while handling connection: #{e.message}"
42
+ details = "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
43
+ error_object.errors << { summary: summary, details: details }
44
+ end
45
+ else
46
+ summary = "Error while saving section_type: #{section_type.name}"
47
+ details = "Error! #{section_type.errors.full_messages.to_sentence}"
48
+ error_object.errors << { summary: summary, details: details }
49
+ end
50
+ return error_object
51
+ end
52
+
53
+ # ------------------
54
+ # Instance variables
55
+ # ------------------
56
+
57
+ # Generic Methods
58
+ # ---------------
59
+ def to_param
60
+ "#{id}-#{name.parameterize[0..32]}"
61
+ end
62
+
63
+ def display_name
64
+ "#{name_was}"
65
+ end
66
+
67
+ # Permission Methods
68
+ # ------------------
69
+
70
+ def can_be_edited?
71
+ true
72
+ end
73
+
74
+ def can_be_deleted?
75
+ true
76
+ end
77
+
78
+ end
@@ -14,7 +14,7 @@
14
14
 
15
15
  <div class="row">
16
16
  <div class="col-md-6 pr-20">
17
- <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::BlogPost").published.select("id, name").order("name ASC").all, editable: true, assoc_display_method: :name} %>
17
+ <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::BlogPost").published.select("id, name").order("priority ASC, name ASC").all, editable: true, assoc_display_method: :name} %>
18
18
  <%= theme_form_assoc_group(@blog_post, :category_id, label: "Choose Category", form_style: "top-bottom", **options) %>
19
19
  </div>
20
20
  <div class="col-md-6 pl-20">
@@ -17,7 +17,7 @@
17
17
  <%= theme_form_field(@price, :sub_title, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
18
18
  </div>
19
19
  <div class="col-md-6">
20
- <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::Price").published.select("id, name").order("name ASC").all, editable: true, assoc_display_method: :name} %>
20
+ <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::Price").published.select("id, name").order("priority ASC, name ASC").all, editable: true, assoc_display_method: :name} %>
21
21
  <%= theme_form_assoc_group(@price, :category_id, label: "Choose Category", form_style: "top-bottom", **options) %>
22
22
  </div>
23
23
  </div>
@@ -1,24 +1,22 @@
1
1
  <tr id="tr_price_<%= price.id %>">
2
-
3
2
  <th scope="row" style="text-align: center;">
4
3
  <%= serial_number(i) %>
5
4
  </th>
6
5
 
7
6
  <td class="display-link">
8
7
  <%= link_to price.title, price_path(price), remote: true %><br>
9
- <%= link_to price.category.try(:display_name), price_path(price), remote: true %>
8
+ <%= link_to price.category.try(:display_name), price_path(price), remote: true, style: "color:darkred" %>
10
9
  </td>
11
10
 
12
11
  <td class="hidden-sm hidden-xs"><%= price.price %></td>
13
-
12
+ <td class="hidden-sm hidden-xs"><%= price.priority %></td>
14
13
  <td class="hidden-sm hidden-xs"><%= display_publishable_status(price) %></td>
15
14
 
16
15
  <% if display_manage_links? %>
17
- <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(price) %></td>
16
+ <td class="action-links hidden-sm hidden-xs" style="width:15%"><%= display_publishable_links(price) %></td>
18
17
 
19
- <td class="action-links hidden-sm hidden-xs" style="width:10%">
18
+ <td class="action-links hidden-sm hidden-xs" style="width:15%">
20
19
  <%= display_manage_links(price, @current_user) %>
21
20
  </td>
22
21
  <% end %>
23
-
24
22
  </tr>
@@ -35,12 +35,12 @@
35
35
  <div id="div_price_action_buttons">
36
36
  <div class="row">
37
37
  <div class="col-sm-6">
38
- <%= theme_button('Add a Price', 'plus', dhatu.new_price_path(), classes: "pull-left mr-10", btn_type: "success") if @current_user.has_create_permission?(Dhatu::Price) %>
38
+ <%= theme_button('Add a Price', 'plus', dhatu.new_price_path(ct: params[:ct]), classes: "pull-left mr-10", btn_type: "success") if @current_user.has_create_permission?(Dhatu::Price) %>
39
39
 
40
- <%= theme_button('Refresh', 'refresh', dhatu.prices_path(st: @status), classes: "pull-left mr-10", btn_type: "white") %>
40
+ <%= theme_button('Refresh', 'refresh', dhatu.prices_path(ct: params[:ct]), classes: "pull-left mr-10", btn_type: "white") %>
41
41
  </div>
42
42
  <div class="col-sm-6">
43
- <%= search_form_kuppayam(Dhatu::Price, dhatu.prices_path(st: @status), text: @filters[:query]) %>
43
+ <%= search_form_kuppayam(Dhatu::Price, dhatu.prices_path(ct: params[:ct]), text: @filters[:query]) %>
44
44
  </div>
45
45
  </div>
46
46
 
@@ -0,0 +1,20 @@
1
+ <%= form_for([@section_type], :html => {:id=>"form_section_type", :class=>"mb-0 form-horizontal", :role => "form", :method => (@section_type.new_record? ? :post : :put), :remote=>true}) do |f| %>
2
+
3
+ <div id="section_type_form_error">
4
+ <%= @section_type.errors[:base].to_sentence %>
5
+ </div>
6
+
7
+ <div class="form-inputs mb-30 mt-30">
8
+ <%= theme_form_field(@section_type, :name, label: "Name") %>
9
+ <%= theme_form_field(@section_type, :code, label: "Code") %>
10
+ </div>
11
+
12
+ <div>
13
+ <%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
14
+ <%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeGenericModal();", class: "pull-right ml-10 btn btn-white" %>
15
+ </div>
16
+ <%= clear_tag(10) %>
17
+ </div>
18
+
19
+ <% end %>
20
+
@@ -0,0 +1,48 @@
1
+ <div class="table-responsive">
2
+ <table class="table table-hover members-table middle-align">
3
+ <thead>
4
+ <tr>
5
+ <th style="text-align: center;width:60px">#</th>
6
+ <th>Name</th>
7
+ <th>Code</th>
8
+ <% if display_manage_links? %>
9
+ <th style="text-align: center;">Actions</th>
10
+ <% end %>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% @section_types.each_with_index do |section_type, i| %>
15
+
16
+ <tr id="tr_section_type_<%= section_type.id %>">
17
+
18
+ <th scope="row" style="text-align: center;">
19
+ <% if i < 0 %>
20
+ <i class="fa fa-check text-success"></i>
21
+ <% else %>
22
+ <%= i + 1 + (@per_page.to_i * (@current_page.to_i - 1)) %>
23
+ <% end %>
24
+ </th>
25
+
26
+ <td class="section_type-name"><%= link_to section_type.display_name, section_type_path(section_type), remote: true %></td>
27
+
28
+ <td class="section_type-name"><%= link_to section_type.code, section_type_path(section_type), remote: true %></td>
29
+
30
+ <% if display_manage_links? %>
31
+
32
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
33
+ <%= display_manage_links(section_type, @current_user) %>
34
+ </td>
35
+ <% end %>
36
+ </tr>
37
+
38
+ <% end %>
39
+ </tbody>
40
+ </table>
41
+ </div>
42
+
43
+ <div class="row">
44
+ <div class="col-sm-12">
45
+ <%= paginate_kuppayam(@section_types) %>
46
+ </div>
47
+ </div>
48
+
@@ -0,0 +1,20 @@
1
+ <tr id="tr_section_type_<%= section_type.id %>">
2
+
3
+ <th scope="row" style="text-align: center;">
4
+ <% if i < 0 %>
5
+ <i class="fa fa-check text-success"></i>
6
+ <% else %>
7
+ <%= i + 1 + (@per_page.to_i * (@current_page.to_i - 1)) %>
8
+ <% end %>
9
+ </th>
10
+
11
+ <td class="section_type-name"><%= link_to section_type.display_name, section_type_path(section_type), remote: true %></td>
12
+
13
+ <td class="section_type-name"><%= link_to section_type.code, section_type_path(section_type), remote: true %></td>
14
+
15
+ <% if display_manage_links? %>
16
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
17
+ <%= display_manage_links(section_type, @current_user) %>
18
+ </td>
19
+ <% end %>
20
+ </tr>
@@ -0,0 +1,41 @@
1
+ <div id="div_blog_post_show">
2
+
3
+ <div class="row">
4
+
5
+ <div class="col-md-9 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
6
+ <%= theme_panel_heading(@section_type.display_name) %>
7
+ <%= theme_panel_sub_heading(@section_type.code, "#") %>
8
+ <%= clear_tag(10) %>
9
+ <div class="table-responsive mb-50">
10
+ <table class="table table-striped table-condensed table-bordered">
11
+ <tbody>
12
+ <tr>
13
+ <th>Name</th><td><%= @section_type.name %></td>
14
+ </tr>
15
+ <tr>
16
+ <th>Code</th><td><%= @section_type.code %></td>
17
+ </tr>
18
+ <tr>
19
+ <th>Created At</th><td><%= @section_type.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @section_type.created_at %></td>
20
+ </tr>
21
+ <tr>
22
+ <th>Updated At</th><td><%= @section_type.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @section_type.updated_at %></td>
23
+ </tr>
24
+
25
+ </tbody>
26
+ </table>
27
+ </div>
28
+ <%= clear_tag(10) %>
29
+ </div>
30
+
31
+ <% if display_manage_links? %>
32
+ <div class="col-md-3 col-sm-12 col-xs-12">
33
+ <%= display_manage_buttons(@section_type) %>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+
38
+ <%= clear_tag(30) %>
39
+ <%= link_to "Close", "#", onclick: "closeGenericModal();", class: "btn btn-primary pull-right" %>
40
+ <%= clear_tag(10) %>
41
+ </div>
@@ -0,0 +1,43 @@
1
+ <div class="row">
2
+
3
+ <div class="col-md-12">
4
+
5
+ <ul class="nav nav-tabs">
6
+ </ul>
7
+ <div class="tab-content">
8
+ <div class="tab-pane active">
9
+
10
+ <div id="div_section_type_action_buttons">
11
+ <div class="row">
12
+ <div class="col-md-6">
13
+
14
+ <%= theme_button('Add a Section Type', 'plus', new_section_type_path(), classes: "pull-left mr-10", btn_type: "success") if @current_user.has_create_permission?(Dhatu::SectionType) %>
15
+
16
+ <%= theme_button('Refresh', 'refresh', section_types_path(), classes: "pull-left mr-10", btn_type: "white") %>
17
+
18
+ </div>
19
+ <div class="col-md-6">
20
+ <%= search_form_kuppayam(Dhatu::SectionType, section_types_path, text: @filters[:query]) %>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ <%= clear_tag(10) %>
25
+
26
+ <div id="div_section_type_index">
27
+ <%= render :partial=>"dhatu/section_types/index" %>
28
+ </div>
29
+ <%= clear_tag(10) %>
30
+
31
+ </div>
32
+ </div>
33
+
34
+ </div>
35
+
36
+ </div>
37
+
38
+ <script type="text/javascript">
39
+ $('body').on('change', '#inp_name', function() {
40
+ var sectionCode = $(this).val().replace(/ /g, '_').toUpperCase().slice(0, 63);
41
+ $('#inp_code').val(sectionCode);
42
+ });
43
+ </script>
@@ -8,50 +8,56 @@
8
8
  <%= @section.errors[:base].to_sentence %>
9
9
  </div>
10
10
 
11
- <div class="form-inputs m-15">
12
-
13
- <% if @section.new_record? || @current_user.super_admin? %>
14
-
15
- <%= theme_form_field(@section, :section_type, form_style: "top-bottom", html_options: { placeholder: ""}) %>
16
-
17
- <% else %>
18
-
19
- <%= theme_form_field(@section, :section_type, form_style: "top-bottom", html_options: { placeholder: "", readonly: true}) %>
20
-
21
- <% end %>
22
-
23
- <%= theme_form_field(@section, :title, form_style: "top-bottom", html_options: { placeholder: ""}) %>
24
-
25
- <%= theme_form_field(@section, :sub_title, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
26
-
27
- <%= theme_form_field(@section, :short_description, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
28
-
29
- <%= theme_form_field(@section, :long_description, required: true, html_options: {type: :textarea, class: "form-control wysihtml5", "data-stylesheet-url": "assets/wysiwyg-color.css"}, form_style: "top-bottom") %>
11
+ <div class="form-inputs">
30
12
 
31
13
  <div class="row">
32
- <div class="col-md-4 pr-20">
33
- <%= theme_form_field(@section, :button_one_text, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
14
+ <div class="col-md-8 pr-20">
15
+ <%= theme_form_field(@section, :title, form_style: "top-bottom", html_options: { placeholder: ""}) %>
16
+ <%= theme_form_field(@section, :sub_title, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
17
+ <%= theme_form_field(@section, :short_description, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
34
18
  </div>
35
19
  <div class="col-md-4 pl-20">
36
- <%= theme_form_field(@section, :button_one_link, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
20
+ <div class="row">
21
+ <div class="col-md-12">
22
+ <% options = {assoc_collection: Dhatu::SectionType.select("id, name").order("name ASC").all, editable: true, assoc_display_method: :name} %>
23
+ <%= theme_form_assoc_group(@section, :section_type_id, label: "Type", form_style: "top-bottom", **options) %>
24
+ </div>
25
+ </div>
26
+ <div class="row">
27
+ <div class="col-md-6 pr-20">
28
+ <%= theme_form_field(@section, :button_one_text, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
29
+ </div>
30
+ <div class="col-md-6 pl-20">
31
+ <%= theme_form_field(@section, :button_one_link, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
32
+ </div>
33
+ </div>
34
+
35
+ <div class="row">
36
+ <div class="col-md-6 pr-20">
37
+ <%= theme_form_field(@section, :button_two_text, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
38
+ </div>
39
+ <div class="col-md-6 pl-20">
40
+ <%= theme_form_field(@section, :button_two_link, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
41
+ </div>
42
+ </div>
43
+
37
44
  </div>
38
45
  </div>
39
-
46
+
40
47
  <div class="row">
41
- <div class="col-md-4 pr-20">
42
- <%= theme_form_field(@section, :button_two_text, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
43
- </div>
44
- <div class="col-md-4 pl-20">
45
- <%= theme_form_field(@section, :button_two_link, required: false, form_style: "top-bottom", html_options: { placeholder: "" }) %>
48
+ <div class="col-md-12 pr-20">
49
+ <%= theme_form_field(@section, :long_description, required: true, html_options: {type: :textarea, class: "form-control wysihtml5", "data-stylesheet-url": "assets/wysiwyg-color.css"}, form_style: "top-bottom") %>
46
50
  </div>
47
51
  </div>
48
-
52
+
49
53
  </div>
50
54
 
51
- <div>
52
- <%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
55
+ <div class="row">
56
+ <div class="col-md-12 pr-20">
57
+ <%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
53
58
 
54
- <%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeLargeModal();", class: "pull-right btn btn-white" %>
59
+ <%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeLargeModal();", class: "pull-right btn btn-white" %>
60
+ </div>
55
61
  </div>
56
62
 
57
63
  <%= clear_tag %>
@@ -1,11 +1,11 @@
1
1
  <div class="table-responsive">
2
- <table class="table table-hover members-table middle-align">
2
+ <table class="table table-hover table-condensed members-table middle-align">
3
3
  <thead>
4
4
  <tr>
5
5
  <th style="text-align: center;width:5%">#</th>
6
- <th style="text-align: center;width:100px"><i class="fa fa-photo"></i></th>
7
- <th style="width:200px">Section Type</th>
8
- <th>Section Title</th>
6
+ <!-- <th style="text-align: center;width:100px"><i class="fa fa-photo"></i></th> -->
7
+ <th>Title</th>
8
+ <th style="width:200px">Type</th>
9
9
  <th style="width:100px;" class="hidden-sm hidden-xs">Status</th>
10
10
  <% if display_manage_links? %>
11
11
  <th style="text-align: center;" colspan="2" class="hidden-sm hidden-xs">Actions</th>
@@ -22,14 +22,14 @@
22
22
  <%= serial_number(i) %>
23
23
  </th>
24
24
 
25
- <td class="display-image">
26
- <%= display_thumbnail_small(section) %>
27
- </td>
28
-
29
- <td class="display-link"><%= link_to section.section_type, section_path(section), remote: true %></td>
25
+ <!-- <td class="display-image">
26
+ <%#= display_thumbnail_small(section) %>
27
+ </td> -->
30
28
 
31
29
  <td class="display-link"><%= link_to section.title, section_path(section), remote: true %></td>
32
30
 
31
+ <td class="display-link"><%= link_to section.section_type.try(:name), section_path(section), remote: true %></td>
32
+
33
33
  <td class="hidden-sm hidden-xs"><%= display_publishable_status(section) %></td>
34
34
 
35
35
  <% if display_manage_links? %>
@@ -1,25 +1,24 @@
1
1
  <tr id="tr_section_<%= section.id %>">
2
2
 
3
- <th scope="row" style="text-align: center;">
4
- <%= serial_number(i) %>
5
- </th>
3
+ <th scope="row" style="text-align: center;">
4
+ <%= serial_number(i) %>
5
+ </th>
6
6
 
7
- <td class="display-image">
8
- <%= display_thumbnail_small(section) %>
9
- </td>
7
+ <!-- <td class="display-image">
8
+ <%#= display_thumbnail_small(section) %>
9
+ </td> -->
10
10
 
11
- <td class="display-link"><%= link_to section.section_type, section_path(section), remote: true %></td>
11
+ <td class="display-link"><%= link_to section.title, section_path(section), remote: true %></td>
12
12
 
13
- <td class="display-link"><%= link_to section.title, section_path(section), remote: true %></td>
13
+ <td class="display-link"><%= link_to section.section_type.try(:name), section_path(section), remote: true %></td>
14
14
 
15
- <td class="hidden-sm hidden-xs"><%= display_publishable_status(section) %></td>
15
+ <td class="hidden-sm hidden-xs"><%= display_publishable_status(section) %></td>
16
16
 
17
- <% if display_manage_links? %>
18
- <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(section) if display_edit_links? %></td>
17
+ <% if display_manage_links? %>
18
+ <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(section) %></td>
19
19
 
20
- <td class="action-links hidden-sm hidden-xs" style="width:10%">
21
- <%= display_manage_links(section, @current_user) if display_delete_links? %>
22
- </td>
23
- <% end %>
24
-
25
- </tr>
20
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
21
+ <%= display_manage_links(section, @current_user) %>
22
+ </td>
23
+ <% end %>
24
+ </tr>
@@ -41,13 +41,4 @@
41
41
 
42
42
  </div>
43
43
 
44
- </div>
45
-
46
- <script type="text/javascript">
47
- $('body').on('change', '#inp_section_type', function() {
48
- var sectionType = $(this).val().replace(/ /g, '_').toUpperCase().slice(0, 63);
49
- $('#inp_section_type').val(sectionType);
50
- });
51
- </script>
52
-
53
-
44
+ </div>
@@ -14,7 +14,7 @@
14
14
 
15
15
  <div class="row">
16
16
  <div class="col-md-4 pr-20">
17
- <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::Service").published.select("id, name").order("name ASC").all, editable: true, assoc_display_method: :name} %>
17
+ <% options = {assoc_collection: Dhatu::Category.filter_by_category_type("Dhatu::Service").published.select("id, name").order("priority ASC, name ASC").all, editable: true, assoc_display_method: :name} %>
18
18
  <%= theme_form_assoc_group(@service, :category_id, label: "Choose Category", form_style: "top-bottom", **options) %>
19
19
  </div>
20
20
  <div class="col-md-4 pl-20">
@@ -38,6 +38,8 @@ Dhatu::Engine.routes.draw do
38
38
  end
39
39
  end
40
40
 
41
+ resources :section_types
42
+
41
43
  resources :sections do
42
44
  member do
43
45
  put :update_status, as: :update_status
@@ -1,3 +1,3 @@
1
1
  module Dhatu
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
@@ -25,7 +25,7 @@ namespace 'dhatu' do
25
25
  puts " "
26
26
  end
27
27
 
28
- ["Feature"].each do |cls_name|
28
+ ["Feature", "Dhatu::SectionType"].each do |cls_name|
29
29
  name = cls_name.underscore.pluralize
30
30
  desc "Import #{cls_name.pluralize}"
31
31
  task name => :environment do
@@ -49,7 +49,7 @@ namespace 'dhatu' do
49
49
  desc "Import all dummy data in sequence"
50
50
  task 'all' => :environment do
51
51
 
52
- import_list = ["features"]
52
+ import_list = ["features", "section_types"]
53
53
 
54
54
  import_list.each do |item|
55
55
  print "Loading #{item.split(':').last.titleize} \t".yellow
@@ -65,7 +65,7 @@ namespace 'dhatu' do
65
65
  puts " "
66
66
  end
67
67
 
68
- ["Feature"].each do |cls_name|
68
+ ["Feature", "Dhatu::SectionType"].each do |cls_name|
69
69
  name = cls_name.underscore.pluralize
70
70
  desc "Load Dummy #{cls_name.pluralize}"
71
71
  task name => :environment do
@@ -25,7 +25,7 @@ namespace 'dhatu' do
25
25
  puts " "
26
26
  end
27
27
 
28
- ["Feature"].each do |cls_name|
28
+ ["Feature", "Dhatu::SectionType"].each do |cls_name|
29
29
  name = cls_name.underscore.pluralize
30
30
  desc "Import #{cls_name.pluralize}"
31
31
  task name => :environment do
@@ -35,7 +35,9 @@ namespace 'dhatu' do
35
35
  destroy_all = false
36
36
  destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip)
37
37
 
38
- path = Dhatu::Engine.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv")
38
+ path = Rails.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv")
39
+ path = Dhatu::Engine.root.join('db', 'master_data', "#{cls_name.constantize.table_name}.csv") unless File.exists?(path)
40
+
39
41
  cls_name.constantize.destroy_all if destroy_all
40
42
  cls_name.constantize.import_data_file(path, true, verbose)
41
43
  # puts "Importing Completed".green if verbose
@@ -1,7 +1,6 @@
1
1
  FactoryGirl.define do
2
2
 
3
3
  factory :unpublished_section, class: Dhatu::Section do
4
-
5
4
  title "Section Title"
6
5
  sub_title "Section Sub Title"
7
6
 
@@ -14,8 +13,7 @@ FactoryGirl.define do
14
13
  button_one_link "www.domain.com/link_one"
15
14
  button_two_link "www.domain.com/link_two"
16
15
 
17
- association :category, factory: :published_section_category
18
-
16
+ association :section_type, factory: :section_type
19
17
  end
20
18
 
21
19
  factory :published_section, parent: :unpublished_section do
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :section_type, class: Dhatu::SectionType do
3
+ name "About Us"
4
+ code "ABOUT_US"
5
+ end
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhatu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-14 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -419,6 +419,7 @@ files:
419
419
  - app/controllers/dhatu/offers_controller.rb
420
420
  - app/controllers/dhatu/prices_controller.rb
421
421
  - app/controllers/dhatu/resource_controller.rb
422
+ - app/controllers/dhatu/section_types_controller.rb
422
423
  - app/controllers/dhatu/sections_controller.rb
423
424
  - app/controllers/dhatu/services_controller.rb
424
425
  - app/controllers/dhatu/team_members_controller.rb
@@ -435,6 +436,7 @@ files:
435
436
  - app/models/dhatu/offer.rb
436
437
  - app/models/dhatu/price.rb
437
438
  - app/models/dhatu/section.rb
439
+ - app/models/dhatu/section_type.rb
438
440
  - app/models/dhatu/service.rb
439
441
  - app/models/dhatu/team_member.rb
440
442
  - app/models/dhatu/testimonial.rb
@@ -477,6 +479,11 @@ files:
477
479
  - app/views/dhatu/prices/_row.html.erb
478
480
  - app/views/dhatu/prices/_show.html.erb
479
481
  - app/views/dhatu/prices/index.html.erb
482
+ - app/views/dhatu/section_types/_form.html.erb
483
+ - app/views/dhatu/section_types/_index.html.erb
484
+ - app/views/dhatu/section_types/_row.html.erb
485
+ - app/views/dhatu/section_types/_show.html.erb
486
+ - app/views/dhatu/section_types/index.html.erb
480
487
  - app/views/dhatu/sections/_form.html.erb
481
488
  - app/views/dhatu/sections/_index.html.erb
482
489
  - app/views/dhatu/sections/_row.html.erb
@@ -525,6 +532,7 @@ files:
525
532
  - spec/dummy/spec/factories/section.rb
526
533
  - spec/dummy/spec/factories/section_cover_image.rb
527
534
  - spec/dummy/spec/factories/section_gallery_image.rb
535
+ - spec/dummy/spec/factories/section_type.rb
528
536
  - spec/dummy/spec/factories/team_member.rb
529
537
  - spec/dummy/spec/factories/test.jpg
530
538
  - spec/dummy/spec/factories/testimonial.rb