"use strict";(self.webpackChunk_aidoop_aidoop_r=self.webpackChunk_aidoop_aidoop_r||[]).push([[8759],{58759:(t,e,i)=>{i.r(e),i.d(e,{NotificationListPage:()=>y});var o=i(50493),s=i(68784),r=i(15633),a=i(77675),n=i(94430),d=i(56765),c=i(69292),l=i(27805),p=i(53421),g=i(37077),h=i(64312),f=i(36179),m=i(28120),u=i(16682);let y=class extends((0,m.$)(a.h)((0,p.NC)(p.z2)((0,c.f)(a.B4)))){constructor(){super(...arguments),this.mode=(0,f.s2)()?"CARD":"GRID"}get context(){var t;return{title:p.z2.t("title.notification list"),search:{handler:t=>{this.grist.searchText=t},value:(null===(t=this.grist)||void 0===t?void 0:t.searchText)||""},filter:{handler:()=>{this.grist.toggleHeadroom()}},help:"notification/notification",actions:[Object.assign({title:p.z2.t("button.save"),action:this._updateNotification.bind(this)},r.jO.save),Object.assign({title:p.z2.t("button.delete"),action:this._deleteNotification.bind(this)},r.jO.delete)]}}render(){const t=this.mode||((0,f.s2)()?"CARD":"GRID");return n.dy`
      <ox-grist .mode=${t} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
        <div slot="headroom">
          <div id="filters">
            <ox-filters-form autofocus></ox-filters-form>
          </div>

          <div id="sorters">
            Sort
            <mwc-icon
              @click=${t=>{const e=t.currentTarget;this.sortersControl.open({right:0,top:e.offsetTop+e.offsetHeight})}}
              >expand_more</mwc-icon
            >
            <ox-popup id="sorter-control">
              <ox-sorters-control> </ox-sorters-control>
            </ox-popup>
          </div>

          <div id="modes">
            <mwc-icon @click=${()=>this.mode="GRID"} ?active=${"GRID"==t}>grid_on</mwc-icon>
            <mwc-icon @click=${()=>this.mode="LIST"} ?active=${"LIST"==t}>format_list_bulleted</mwc-icon>
            <mwc-icon @click=${()=>this.mode="CARD"} ?active=${"CARD"==t}>apps</mwc-icon>
          </div>
        </div>
      </ox-grist>
    `}async pageInitialized(t){this.gristConfig={list:{fields:["title","body"],details:["state","updatedAt"]},columns:[{type:"gutter",gutterName:"sequence"},{type:"gutter",gutterName:"row-selector",multiple:!0},{type:"string",name:"title",header:p.z2.t("field.title"),record:{editable:!1},filter:"search",sortable:!0,width:150},{type:"string",name:"body",header:p.z2.t("field.body"),record:{editable:!1},filter:"search",width:200},{type:"checkbox",name:"state",label:!0,header:p.z2.t("field.state"),record:{editable:!0},filter:!0,sortable:!0,width:60},{type:"datetime",name:"createdAt",header:p.z2.t("field.created_at"),record:{editable:!1},sortable:!0,width:180}],rows:{selectable:{multiple:!0}},sorters:[{name:"createdAt",desc:!0}]}}async pageUpdated(t,e){this.active}async fetchHandler({page:t=1,limit:e=100,sortings:i=[],filters:o=[]}){const s=await l.Lp.query({query:u.ZP`
        query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
          responses: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {
            items {
              id
              title
              body
              state
              createdAt
            }
            total
          }
        }
      `,variables:{filters:o,pagination:{page:t,limit:e},sortings:i}});return{total:s.data.responses.total||0,records:s.data.responses.items||[]}}async _deleteNotification(){if(confirm(p.z2.t("text.sure_to_x",{x:p.z2.t("text.delete")}))){const t=this.grist.selected.map((t=>t.id));if(t&&t.length>0){(await l.Lp.mutate({mutation:u.ZP`
            mutation ($ids: [String!]!) {
              deleteNotificationes(ids: $ids)
            }
          `,variables:{ids:t}})).errors||(this.grist.fetch(),(0,g.h4)({message:p.z2.t("text.info_x_successfully",{x:p.z2.t("text.delete")})}))}}}async _updateNotification(){let t=this.grist.dirtyRecords;if(t&&t.length){t=t.map((t=>{let e=t.id?{id:t.id}:{};const i=t.__dirtyfields__;for(let t in i)e[t]=i[t].after;return e.cuFlag=t.__dirty__,e}));(await l.Lp.mutate({mutation:u.ZP`
          mutation ($patches: [NotificationPatch!]!) {
            updateMultipleNotification(patches: $patches) {
              name
            }
          }
        `,variables:{patches:t}})).errors||this.grist.fetch()}}};y.styles=[r.Ix,r.Pn,n.iv`
      :host {
        display: flex;

        width: 100%;

        --grid-record-emphasized-background-color: red;
        --grid-record-emphasized-color: yellow;
      }
    `],(0,o.gn)([(0,d.Cb)({type:Object}),(0,o.w6)("design:type",Object)],y.prototype,"gristConfig",void 0),(0,o.gn)([(0,d.Cb)({type:String}),(0,o.w6)("design:type",String)],y.prototype,"mode",void 0),(0,o.gn)([(0,d.IO)("ox-grist"),(0,o.w6)("design:type",s.Nw)],y.prototype,"grist",void 0),(0,o.gn)([(0,d.IO)("#sorter-control"),(0,o.w6)("design:type",h.WP)],y.prototype,"sortersControl",void 0),y=(0,o.gn)([(0,d.Mo)("notification-list-page")],y)}}]);