| @@ -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", |
| @@ -212,9 +219,12 @@ | ||
| 212 | 219 | } |
| 213 | 220 | migratedOnce.current = true; |
| 214 | 221 | let ids = normalizeIds(attributes2.activityIds); |
| 215 | 222 | if (ids.length === 0) { |
| 216 | - ids = migrateNumericCsvPairToIds(attributes2.activity_ids, attributes2.activity); | |
| 223 | + ids = migrateNumericCsvPairToIds( | |
| 224 | + attributes2.activity_ids, | |
| 225 | + attributes2.activity | |
| 226 | + ); | |
| 217 | 227 | } |
| 218 | 228 | if (ids.length === 0) { |
| 219 | 229 | return; |
| 220 | 230 | } |
| @@ -283,8 +293,40 @@ | ||
| 283 | 293 | ), |
| 284 | 294 | value: activityIds, |
| 285 | 295 | onChange: (ids) => setAttributes({ activityIds: ids }) |
| 286 | 296 | } |
| 297 | + )), /* @__PURE__ */ element.createElement(components.PanelBody, { title: i18n.__("Display options", "yatra"), initialOpen: false }, /* @__PURE__ */ element.createElement( | |
| 298 | + components.ToggleControl, | |
| 299 | + { | |
| 300 | + label: i18n.__("Show trip count", "yatra"), | |
| 301 | + checked: attributes2.show_trip_count, | |
| 302 | + onChange: (value) => setAttributes({ show_trip_count: value }) | |
| 303 | + } | |
| 304 | + ), /* @__PURE__ */ element.createElement( | |
| 305 | + components.ToggleControl, | |
| 306 | + { | |
| 307 | + label: i18n.__("Show description", "yatra"), | |
| 308 | + checked: attributes2.show_description, | |
| 309 | + onChange: (value) => setAttributes({ show_description: value }) | |
| 310 | + } | |
| 311 | + ), /* @__PURE__ */ element.createElement( | |
| 312 | + components.ToggleControl, | |
| 313 | + { | |
| 314 | + label: i18n.__("Show image", "yatra"), | |
| 315 | + checked: attributes2.show_image, | |
| 316 | + onChange: (value) => setAttributes({ show_image: value }) | |
| 317 | + } | |
| 318 | + ), /* @__PURE__ */ element.createElement( | |
| 319 | + components.ToggleControl, | |
| 320 | + { | |
| 321 | + label: i18n.__("Hide empty activities", "yatra"), | |
| 322 | + help: i18n.__( | |
| 323 | + "Skip activities that have no published trips assigned. Off by default — turn on for a tighter live catalog, leave off for editorial / onboarding views.", | |
| 324 | + "yatra" | |
| 325 | + ), | |
| 326 | + checked: attributes2.hide_empty, | |
| 327 | + onChange: (value) => setAttributes({ hide_empty: value }) | |
| 328 | + } | |
| 287 | 329 | ))), /* @__PURE__ */ element.createElement("div", { className: "yatra-block-editor-preview" }, /* @__PURE__ */ element.createElement( |
| 288 | 330 | ServerSideRender, |
| 289 | 331 | { |
| 290 | 332 | block: "yatra/activity", |
| @@ -329,8 +371,25 @@ | ||
| 329 | 371 | }, |
| 330 | 372 | activityIds: { |
| 331 | 373 | type: "array", |
| 332 | 374 | "default": [] |
| 375 | + }, | |
| 376 | + hide_empty: { | |
| 377 | + type: "boolean", | |
| 378 | + "default": false, | |
| 379 | + description: "When on, activities with zero published trips are skipped. Off by default to preserve the historical 'show everything' behavior." | |
| 380 | + }, | |
| 381 | + show_trip_count: { | |
| 382 | + type: "boolean", | |
| 383 | + "default": true | |
| 384 | + }, | |
| 385 | + show_description: { | |
| 386 | + type: "boolean", | |
| 387 | + "default": true | |
| 388 | + }, | |
| 389 | + show_image: { | |
| 390 | + type: "boolean", | |
| 391 | + "default": true | |
| 333 | 392 | } |
| 334 | 393 | }; |
| 335 | 394 | const supports = { |
| 336 | 395 | html: false, |