沒登入也可以看到日曆,沒有開放預約時,管理者仍可以在前臺預約

This commit is contained in:
邱博亞 2023-08-26 11:16:56 +08:00
parent c3eb6f7ac8
commit 864358bd69
6 changed files with 29 additions and 21 deletions

View File

@ -30,13 +30,14 @@ class PropertyHiresController < ApplicationController
data = properties.collect do |property|
actions = []
url_to_show = "#{url}/#{property.to_param}"
if property.can_be_hired
if property.can_be_hired_frontend
hire_url = url_to_show + "?method=hire"
actions << {
"text" => t("property_hire.hire"),
"btn-class" => "btn-primary",
"link" => hire_url
}
end
unless property.disable_view_calendar_page
actions << {
"text" => t("property_hire.view_calendar"),
@ -45,7 +46,10 @@ class PropertyHiresController < ApplicationController
}
end
if property.disable_content_page
if hire_url
url_to_show = hire_url
elsif !property.disable_view_calendar_page
url_to_show += "?method=view_calendar"
end
end
{
@ -157,12 +161,13 @@ class PropertyHiresController < ApplicationController
end
actions = []
url_to_show = OrbitHelper.url_to_show(property.to_param)
if property.can_be_hired
if property.can_be_hired_frontend
actions << {
"text" => t("property_hire.hire"),
"btn-class" => "btn-primary",
"link" => url_to_show + "?method=hire"
}
end
unless property.disable_view_calendar_page
actions << {
"text" => t("property_hire.view_calendar"),
@ -170,7 +175,6 @@ class PropertyHiresController < ApplicationController
"link" => url_to_show + "?method=view_calendar"
}
end
end
{
"data" => data,
"actions" => actions,

View File

@ -561,4 +561,8 @@ class Property
self.enable_fields_sort ? self.custom_field_names : self.default_field_names
end
end
def can_be_hired_frontend
user = OrbitHelper.current_user
self.can_be_hired || (user && (user.is_admin? || property.owners.include?(user.member_profile_id)))
end
end

View File

@ -327,7 +327,7 @@ ul.list-unstyled li {
width: 100%;
}
</style>
<% if !property.can_be_hired %>
<% if !property.can_be_hired_frontend %>
<script type="text/javascript">
alert("This property is unavailable for hire.");
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";

View File

@ -171,7 +171,7 @@
margin-left: 0;
}
</style>
<% if !property.can_be_hired %>
<% if !property.can_be_hired_frontend %>
<script type="text/javascript">
alert("This property is unavailable for hire.");
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";

View File

@ -10,7 +10,7 @@
url = data["page"]
current_user = data["current_user"]
%>
<% if !property.can_be_hired %>
<% if !property.can_be_hired_frontend %>
<script type="text/javascript">
alert("This property is unavailable for hire.");
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";

View File

@ -7,7 +7,7 @@
property = data["property"]
url = data["url"]
%>
<% if !property.can_be_hired %>
<% if property.disable_view_calendar_page %>
<script type="text/javascript">
alert("This property is unavailable for hire.");
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";