web-mojo 2.2.56 → 2.2.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin.es.js CHANGED
@@ -10,7 +10,7 @@ import { M as MapView, a as MetricsCountryMapView } from "./chunks/MetricsCountr
10
10
  import { M as Model, C as Collection } from "./chunks/Collection-DaiL0uGl.js";
11
11
  import { L as LightboxGallery, P as PDFViewer } from "./chunks/PDFViewer-EJ9cOfPF.js";
12
12
  import { W } from "./chunks/WebApp-6qvqmOts.js";
13
- import { B, a, V, b, c, d } from "./chunks/version-MS6IWlRk.js";
13
+ import { B, a, V, b, c, d } from "./chunks/version-OyPGnx30.js";
14
14
  class AdminHeaderView extends View {
15
15
  constructor(options = {}) {
16
16
  super({
@@ -2419,7 +2419,8 @@ class ApiKeyView extends View {
2419
2419
  this.addChild(apiKeyMenu);
2420
2420
  }
2421
2421
  async onActionEditKey() {
2422
- const resp = await Dialog$1.showModelForm({
2422
+ const app = this.getApp();
2423
+ const resp = await app.showModelForm({
2423
2424
  title: `Edit API Key — ${this.model.get("name")}`,
2424
2425
  model: this.model,
2425
2426
  formConfig: ApiKeyForms.edit
@@ -2429,14 +2430,14 @@ class ApiKeyView extends View {
2429
2430
  }
2430
2431
  }
2431
2432
  async onActionDeactivateKey() {
2432
- const confirmed = await Dialog$1.confirm({
2433
+ const app = this.getApp();
2434
+ const confirmed = await app.confirm({
2433
2435
  title: "Deactivate API Key",
2434
2436
  message: `Deactivate "${this.model.get("name")}"? Requests using this key will be rejected.`,
2435
2437
  confirmLabel: "Deactivate",
2436
2438
  confirmClass: "btn-warning"
2437
2439
  });
2438
2440
  if (!confirmed) return;
2439
- const app = this.getApp();
2440
2441
  app.showLoading();
2441
2442
  const resp = await this.model.save({ is_active: false });
2442
2443
  app.hideLoading();
@@ -2460,14 +2461,14 @@ class ApiKeyView extends View {
2460
2461
  }
2461
2462
  }
2462
2463
  async onActionDeleteKey() {
2463
- const confirmed = await Dialog$1.confirm({
2464
+ const app = this.getApp();
2465
+ const confirmed = await app.confirm({
2464
2466
  title: "Delete API Key",
2465
2467
  message: `Permanently delete "${this.model.get("name")}"? This cannot be undone.`,
2466
2468
  confirmLabel: "Delete",
2467
2469
  confirmClass: "btn-danger"
2468
2470
  });
2469
2471
  if (!confirmed) return;
2470
- const app = this.getApp();
2471
2472
  app.showLoading();
2472
2473
  const resp = await this.model.delete();
2473
2474
  app.hideLoading();
@@ -2480,6 +2481,8 @@ class ApiKeyView extends View {
2480
2481
  }
2481
2482
  }
2482
2483
  ApiKey.VIEW_CLASS = ApiKeyView;
2484
+ ApiKey.ADD_FORM = ApiKeyForms.create;
2485
+ ApiKey.EDIT_FORM = ApiKeyForms.edit;
2483
2486
  class ApiKeyTablePage extends TablePage {
2484
2487
  constructor(options = {}) {
2485
2488
  super({
@@ -2523,35 +2526,31 @@ class ApiKeyTablePage extends TablePage {
2523
2526
  }
2524
2527
  });
2525
2528
  }
2526
- /**
2527
- * Override onAdd to show the create form and display the token on success.
2528
- * The token is only returned at creation time — display it in an alert.
2529
- */
2530
- async onAdd() {
2529
+ // Override to intercept and show the one-time token after model.save()
2530
+ async onActionAdd() {
2531
2531
  const app = this.getApp();
2532
- const data = await Dialog$1.showForm({
2533
- title: "Create API Key",
2534
- formConfig: ApiKeyForms.create,
2535
- size: "md"
2532
+ const model = new ApiKey();
2533
+ const result = await app.showForm({
2534
+ model,
2535
+ ...ApiKeyForms.create
2536
2536
  });
2537
- if (!data) return;
2538
- app.showLoading();
2539
- const resp = await app.rest.POST("/api/group/apikey", data);
2540
- app.hideLoading();
2541
- if (resp && resp.status) {
2542
- const token = resp.data?.token;
2543
- await Dialog$1.alert({
2544
- title: "API Key Created",
2545
- message: token ? `Copy this token now it will not be shown again.
2537
+ if (!result) return;
2538
+ const resp = await model.save(result);
2539
+ if (!resp?.data?.status) {
2540
+ app.showError(resp?.data?.error || "Failed to create API key");
2541
+ return;
2542
+ }
2543
+ const token = resp.data?.data?.token;
2544
+ await app.showAlert({
2545
+ title: "API Key CreatedSave Your Token",
2546
+ message: token ? `Copy this token now. It will not be shown again.
2546
2547
 
2547
2548
  ${token}` : "API key created successfully.",
2548
- type: token ? "warning" : "success",
2549
- size: "lg"
2550
- });
2551
- this.collection.fetch();
2552
- } else {
2553
- app.toast.error(resp?.error || "Failed to create API key");
2554
- }
2549
+ type: token ? "warning" : "success",
2550
+ size: "lg"
2551
+ });
2552
+ this.collection.add(model);
2553
+ this.tableView?.refresh();
2555
2554
  }
2556
2555
  }
2557
2556
  class IncidentDashboardHeader extends View {