add widget
This commit is contained in:
		
							parent
							
								
									336c940457
								
							
						
					
					
						commit
						f8e8653c5c
					
				| 
						 | 
				
			
			@ -2,10 +2,34 @@ class PropertyHiresController < ApplicationController
 | 
			
		|||
  include Admin::PropertyHiresHelper
 | 
			
		||||
  FrontendMethods = ["hire", "view_calendar", "hire_success"]
 | 
			
		||||
  def index
 | 
			
		||||
    properties = Property.filter_by_categories.filter_by_tags.sort_order
 | 
			
		||||
    properties = Property.filter_by_categories.sort_order
 | 
			
		||||
    url = "/#{I18n.locale}#{OrbitHelper.page.get_url}"
 | 
			
		||||
    data = index_data(properties, url)
 | 
			
		||||
    headers = [
 | 
			
		||||
      {
 | 
			
		||||
        "column" => t("property_hire.title")
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "column" => ""
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "column" => t("property_hire.location")
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "column" => t("property_hire.actions")
 | 
			
		||||
      }
 | 
			
		||||
    ]
 | 
			
		||||
    {
 | 
			
		||||
      "properties" => data,
 | 
			
		||||
      "headers" => headers,
 | 
			
		||||
      "total_pages" => (properties.total_pages rescue 1)
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index_data(properties, url)
 | 
			
		||||
    data = properties.collect do |property|
 | 
			
		||||
      actions = []
 | 
			
		||||
      url_to_show = OrbitHelper.url_to_show(property.to_param)
 | 
			
		||||
      actions = [] 
 | 
			
		||||
      url_to_show = "#{url}/#{property.to_param}"
 | 
			
		||||
      if property.can_be_hired
 | 
			
		||||
        hire_url = url_to_show + "?method=hire"
 | 
			
		||||
        actions << {
 | 
			
		||||
| 
						 | 
				
			
			@ -33,13 +57,16 @@ class PropertyHiresController < ApplicationController
 | 
			
		|||
        "actions" => actions
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def widget
 | 
			
		||||
    properties = Property.filter_by_widget_categories.sort_order
 | 
			
		||||
    url = OrbitHelper.get_current_widget.get_read_more_page_url
 | 
			
		||||
    data = index_data(properties, url)
 | 
			
		||||
    headers = [
 | 
			
		||||
      {
 | 
			
		||||
        "column" => t("property_hire.title")
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "column" => ""
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "column" => t("property_hire.location")
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +77,7 @@ class PropertyHiresController < ApplicationController
 | 
			
		|||
    {
 | 
			
		||||
      "properties" => data,
 | 
			
		||||
      "headers" => headers,
 | 
			
		||||
      "total_pages" => properties.total_pages
 | 
			
		||||
      "total_pages" => (properties.total_pages rescue 1)
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
<table class="table table-striped">
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr data-list="headers" data-level="0">
 | 
			
		||||
			<th>{{column}}</th>
 | 
			
		||||
		</tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody data-list="properties" data-level="0">
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td><a href="{{url_to_show}}">{{title}}</a></td>
 | 
			
		||||
			<td>{{location}}</td>
 | 
			
		||||
			<td data-list="actions" data-level="1">
 | 
			
		||||
				<a href="{{link}}" class="btn {{btn-class}}">{{text}}</a>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
{{pagination_goes_here}}
 | 
			
		||||
| 
						 | 
				
			
			@ -24,5 +24,15 @@
 | 
			
		|||
                },
 | 
			
		||||
            "thumbnail" : "event_news_thumb2.png"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "widgets" : [
 | 
			
		||||
        {
 | 
			
		||||
            "filename" : "widget1",
 | 
			
		||||
            "name" : {
 | 
			
		||||
                "zh_tw" : "1. 列表",
 | 
			
		||||
                "en" : "1. List"
 | 
			
		||||
                },
 | 
			
		||||
            "thumbnail" : "thumb.png"
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue