| @@ -85,9 +85,16 @@ | ||
| 85 | 85 | { |
| 86 | 86 | className: "yatra-block-taxonomy-field", |
| 87 | 87 | style: { margin: "0 0 16px", border: "none", padding: 0 } |
| 88 | 88 | }, |
| 89 | - /* @__PURE__ */ element.createElement("legend", { className: "components-base-control__label", style: { padding: 0 } }, label), | |
| 89 | + /* @__PURE__ */ element.createElement( | |
| 90 | + "legend", | |
| 91 | + { | |
| 92 | + className: "components-base-control__label", | |
| 93 | + style: { padding: 0 } | |
| 94 | + }, | |
| 95 | + label | |
| 96 | + ), | |
| 90 | 97 | /* @__PURE__ */ element.createElement(components.Spinner, null) |
| 91 | 98 | ); |
| 92 | 99 | } |
| 93 | 100 | return /* @__PURE__ */ element.createElement( |
| @@ -144,30 +151,30 @@ | ||
| 144 | 151 | value: search, |
| 145 | 152 | onChange: (s) => setSearch(s), |
| 146 | 153 | __nextHasNoMarginBottom: true |
| 147 | 154 | } |
| 148 | - ), value.length > 0 && /* @__PURE__ */ element.createElement("p", { className: "components-base-control__help", style: { marginTop: 4 } }, i18n.sprintf( | |
| 149 | - /* translators: %d = number of selected taxonomy items */ | |
| 150 | - i18n.__("%d selected", "yatra"), | |
| 151 | - value.length | |
| 152 | - )), items.length === 0 && !loadError ? /* @__PURE__ */ element.createElement("p", { className: "components-base-control__help" }, i18n.__("No published items of this type yet.", "yatra")) : /* @__PURE__ */ element.createElement("div", { role: "group", "aria-label": label, style: listWrapStyle }, filteredItems.length === 0 ? /* @__PURE__ */ element.createElement("p", { style: { padding: "8px 12px", margin: 0, fontSize: 12 } }, i18n.__("No matching items.", "yatra")) : filteredItems.map((item) => { | |
| 155 | + ), value.length > 0 && /* @__PURE__ */ element.createElement( | |
| 156 | + "p", | |
| 157 | + { | |
| 158 | + className: "components-base-control__help", | |
| 159 | + style: { marginTop: 4 } | |
| 160 | + }, | |
| 161 | + i18n.sprintf( | |
| 162 | + /* translators: %d = number of selected taxonomy items */ | |
| 163 | + i18n.__("%d selected", "yatra"), | |
| 164 | + value.length | |
| 165 | + ) | |
| 166 | + ), items.length === 0 && !loadError ? /* @__PURE__ */ element.createElement("p", { className: "components-base-control__help" }, i18n.__("No published items of this type yet.", "yatra")) : /* @__PURE__ */ element.createElement("div", { role: "group", "aria-label": label, style: listWrapStyle }, filteredItems.length === 0 ? /* @__PURE__ */ element.createElement("p", { style: { padding: "8px 12px", margin: 0, fontSize: 12 } }, i18n.__("No matching items.", "yatra")) : filteredItems.map((item) => { | |
| 153 | 167 | const cid = Number(item.id); |
| 154 | - return /* @__PURE__ */ element.createElement( | |
| 155 | - "div", | |
| 168 | + return /* @__PURE__ */ element.createElement("div", { key: cid, style: { padding: "2px 8px" } }, /* @__PURE__ */ element.createElement( | |
| 169 | + components.CheckboxControl, | |
| 156 | 170 | { |
| 157 | - key: cid, | |
| 158 | - style: { padding: "2px 8px" } | |
| 159 | - }, | |
| 160 | - /* @__PURE__ */ element.createElement( | |
| 161 | - components.CheckboxControl, | |
| 162 | - { | |
| 163 | - label: `${item.name} (${cid})`, | |
| 164 | - checked: selectedSet.has(cid), | |
| 165 | - onChange: (checked) => toggleId(cid, checked === true), | |
| 166 | - __nextHasNoMarginBottom: true | |
| 167 | - } | |
| 168 | - ) | |
| 169 | - ); | |
| 171 | + label: `${item.name} (${cid})`, | |
| 172 | + checked: selectedSet.has(cid), | |
| 173 | + onChange: (checked) => toggleId(cid, checked === true), | |
| 174 | + __nextHasNoMarginBottom: true | |
| 175 | + } | |
| 176 | + )); | |
| 170 | 177 | })), value.length > 0 && /* @__PURE__ */ element.createElement( |
| 171 | 178 | components.Button, |
| 172 | 179 | { |
| 173 | 180 | variant: "link", |
| @@ -298,9 +305,52 @@ | ||
| 298 | 305 | value: destinationIds, |
| 299 | 306 | onChange: (ids) => setAttributes({ destinationIds: ids }) |
| 300 | 307 | } |
| 301 | 308 | ) |
| 302 | - )), /* @__PURE__ */ element.createElement("div", { className: "yatra-block-editor-preview" }, /* @__PURE__ */ element.createElement( | |
| 309 | + ), /* @__PURE__ */ element.createElement(components.PanelBody, { title: i18n.__("Display options", "yatra"), initialOpen: false }, /* @__PURE__ */ element.createElement( | |
| 310 | + components.ToggleControl, | |
| 311 | + { | |
| 312 | + label: i18n.__("Show trip count", "yatra"), | |
| 313 | + checked: attributes2.show_trip_count, | |
| 314 | + onChange: (value) => setAttributes({ show_trip_count: value }) | |
| 315 | + } | |
| 316 | + ), /* @__PURE__ */ element.createElement( | |
| 317 | + components.ToggleControl, | |
| 318 | + { | |
| 319 | + label: i18n.__("Show description", "yatra"), | |
| 320 | + checked: attributes2.show_description, | |
| 321 | + onChange: (value) => setAttributes({ show_description: value }) | |
| 322 | + } | |
| 323 | + ), /* @__PURE__ */ element.createElement( | |
| 324 | + components.ToggleControl, | |
| 325 | + { | |
| 326 | + label: i18n.__("Show image", "yatra"), | |
| 327 | + checked: attributes2.show_image, | |
| 328 | + onChange: (value) => setAttributes({ show_image: value }) | |
| 329 | + } | |
| 330 | + ), /* @__PURE__ */ element.createElement( | |
| 331 | + components.ToggleControl, | |
| 332 | + { | |
| 333 | + label: i18n.__("Hide empty destinations", "yatra"), | |
| 334 | + help: i18n.__( | |
| 335 | + "Skip destinations that have no published trips assigned. Off by default — turn on for a tighter live catalog, leave off for editorial / onboarding views.", | |
| 336 | + "yatra" | |
| 337 | + ), | |
| 338 | + checked: attributes2.hide_empty, | |
| 339 | + onChange: (value) => setAttributes({ hide_empty: value }) | |
| 340 | + } | |
| 341 | + ), /* @__PURE__ */ element.createElement( | |
| 342 | + components.ToggleControl, | |
| 343 | + { | |
| 344 | + label: i18n.__("Featured only (filter list)", "yatra"), | |
| 345 | + help: i18n.__( | |
| 346 | + "When on, only destinations marked as featured in Yatra → Destinations are listed.", | |
| 347 | + "yatra" | |
| 348 | + ), | |
| 349 | + checked: attributes2.featured_only, | |
| 350 | + onChange: (value) => setAttributes({ featured_only: value }) | |
| 351 | + } | |
| 352 | + ))), /* @__PURE__ */ element.createElement("div", { className: "yatra-block-editor-preview" }, /* @__PURE__ */ element.createElement( | |
| 303 | 353 | ServerSideRender, |
| 304 | 354 | { |
| 305 | 355 | block: "yatra/destination", |
| 306 | 356 | attributes: attributes2, |
| @@ -345,8 +395,29 @@ | ||
| 345 | 395 | }, |
| 346 | 396 | destinationIds: { |
| 347 | 397 | type: "array", |
| 348 | 398 | "default": [] |
| 399 | + }, | |
| 400 | + hide_empty: { | |
| 401 | + type: "boolean", | |
| 402 | + "default": false, | |
| 403 | + description: "When on, destinations with zero published trips are skipped. Off by default to preserve the historical 'show everything' behavior." | |
| 404 | + }, | |
| 405 | + featured_only: { | |
| 406 | + type: "boolean", | |
| 407 | + "default": false | |
| 408 | + }, | |
| 409 | + show_trip_count: { | |
| 410 | + type: "boolean", | |
| 411 | + "default": true | |
| 412 | + }, | |
| 413 | + show_description: { | |
| 414 | + type: "boolean", | |
| 415 | + "default": true | |
| 416 | + }, | |
| 417 | + show_image: { | |
| 418 | + type: "boolean", | |
| 419 | + "default": true | |
| 349 | 420 | } |
| 350 | 421 | }; |
| 351 | 422 | const supports = { |
| 352 | 423 | html: false, |