extends ../layouts/main
block content

  .uk-margin
    div(uk-grid)
      .uk-width-expand
        h1.uk-text-truncate Pages
      .uk-width-auto
        a(href="/admin/page/compose").uk-button.dtp-button-primary
          +renderButtonIcon('fa-plus', 'New Page')

  .uk-margin
    if (Array.isArray(pages) && (pages.length > 0))

      ul.uk-list

        each page in pages

          li(data-page-id= page._id)
            div(uk-grid).uk-grid-small.uk-flex-middle
              .uk-width-expand
                a(href=`/page/${page.slug}`).uk-display-block.uk-text-large.uk-text-truncate #{page.title}

              .uk-width-auto
                div(uk-grid).uk-grid-small.uk-flex-middle
                  .uk-width-auto(class={
                    'uk-text-info': (page.status === 'draft'),
                    'uk-text-success': (page.status === 'published'),
                    'uk-text-danger': (page.status === 'archived'),
                  })= page.status
                  .uk-width-auto
                    a(href=`/admin/page/${page._id}`).uk-button.dtp-button-primary
                      +renderButtonIcon('fa-pen', 'Edit')
                  .uk-width-auto
                    button(
                      type="button",
                      data-page-id= page._id,
                      data-page-title= page.title,
                      onclick="return dtp.adminApp.deletePage(event);",
                    ).uk-button.dtp-button-danger
                      +renderButtonIcon('fa-trash', 'Delete')
    else
      div There are no pages at this time.