Commit 8639e8f8 authored by droces's avatar droces

Added a 'min nights' field to bookables, and enforced it on booking form

parent 990e648b
......@@ -252,7 +252,9 @@ function check_date_field_valid_value(field) {
}
// console.log('num_nights: ', num_nights);
var min_nights = 2;
var min_nights = parseInt(Drupal.abookings.get_bookable_data()['field_min_guests']);
min_nights = (min_nights) ? min_nights : 1;
console.log('min_nights: ', min_nights);
var min_nights_valid = num_nights >= min_nights;
if (! min_nights_valid) {
alert('Sorry, you cannot book for fewer than ' + min_nights + ' nights.');
......
......@@ -8,6 +8,7 @@ dependencies:
- field.field.node.bookable_unit.field_checkout_time
- field.field.node.bookable_unit.field_max_guests
- field.field.node.bookable_unit.field_min_guests
- field.field.node.bookable_unit.field_min_nights
- field.field.node.bookable_unit.field_price_type
- node.type.bookable_unit
module:
......@@ -19,7 +20,7 @@ mode: default
content:
body:
type: text_textarea_with_summary
weight: 6
weight: 7
settings:
rows: 9
summary_rows: 3
......@@ -27,13 +28,13 @@ content:
third_party_settings: { }
region: content
field_addons:
weight: 7
weight: 8
settings: { }
third_party_settings: { }
type: options_buttons
region: content
field_checkin_time:
weight: 3
weight: 4
settings:
size: 60
placeholder: ''
......@@ -41,7 +42,7 @@ content:
type: string_textfield
region: content
field_checkout_time:
weight: 4
weight: 5
settings:
size: 60
placeholder: ''
......@@ -62,8 +63,15 @@ content:
third_party_settings: { }
type: number
region: content
field_min_nights:
weight: 3
settings:
placeholder: ''
third_party_settings: { }
type: number
region: content
field_price_type:
weight: 5
weight: 6
settings: { }
third_party_settings: { }
type: options_buttons
......
......@@ -8,6 +8,7 @@ dependencies:
- field.field.node.bookable_unit.field_checkout_time
- field.field.node.bookable_unit.field_max_guests
- field.field.node.bookable_unit.field_min_guests
- field.field.node.bookable_unit.field_min_nights
- field.field.node.bookable_unit.field_price_type
- node.type.bookable_unit
module:
......@@ -68,6 +69,15 @@ content:
third_party_settings: { }
type: number_integer
region: content
field_min_nights:
weight: 8
label: above
settings:
thousand_separator: ''
prefix_suffix: true
third_party_settings: { }
type: number_integer
region: content
field_price_type:
weight: 4
label: inline
......
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_min_nights
- node.type.bookable_unit
id: node.bookable_unit.field_min_nights
field_name: field_min_nights
entity_type: node
bundle: bookable_unit
label: 'Minimum nights'
description: ''
required: false
translatable: true
default_value:
-
value: 2
default_value_callback: ''
settings:
min: 1
max: null
prefix: ''
suffix: nights
field_type: integer
......@@ -7,6 +7,7 @@ dependencies:
- field.storage.node.field_checkout_time
- field.storage.node.field_max_guests
- field.storage.node.field_min_guests
- field.storage.node.field_min_nights
- field.storage.node.field_price_type
- node.type.bookable_unit
module:
......@@ -533,6 +534,70 @@ display:
separator: ', '
field_api_classes: false
plugin_id: field
field_min_nights:
id: field_min_nights
table: node__field_min_nights
field: field_min_nights
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
plugin_id: field
filters:
status:
value: '1'
......@@ -657,6 +722,7 @@ display:
- 'config:field.storage.node.field_checkout_time'
- 'config:field.storage.node.field_max_guests'
- 'config:field.storage.node.field_min_guests'
- 'config:field.storage.node.field_min_nights'
- 'config:field.storage.node.field_price_type'
rest_export_1:
display_plugin: rest_export
......@@ -703,4 +769,5 @@ display:
- 'config:field.storage.node.field_checkout_time'
- 'config:field.storage.node.field_max_guests'
- 'config:field.storage.node.field_min_guests'
- 'config:field.storage.node.field_min_nights'
- 'config:field.storage.node.field_price_type'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment