extends ../layouts/main
block content
  
  - var formAction = link ? `/admin/site-link/${link._id}` : '/admin/site-link';

  form(method="POST", action= formAction).uk-form
    .uk-card.uk-card-secondary.uk-card-small
      .uk-card-header
        h1.uk-card-title= link ? 'Update Site Link' : 'Add Site Link'
      .uk-card-body
        .uk-margin
          label(for="label").uk-form-label Label
          input(id="label", name="label", type="text", placeholder="Enter menu label", value= link ? link.label : undefined).uk-input

        .uk-margin
          label(for="url").uk-form-label Target URL
          input(id="url", name="url", type="url", placeholder="Enter URL", value= link ? link.url : undefined).uk-input

        .uk-margin
          .pretty.p-default
            input(id="target-blank", name="targetBlank", type="checkbox", checked= link ? link.target === '_blank' : false)
            .state
              label Open in new window/tab

      div(uk-grid).uk-card-footer
        .uk-width-expand
          +renderBackButton({ includeLabel: true, label: 'Cancel' })
        if link
          .uk-width-auto
            button(
              type="button",
              data-link={ _id: link._id, label: link.label },
              onclick="return dtp.adminApp.deleteSiteLink(event);",
            ).uk-button.dtp-button-danger.uk-border-rounded
              span
                i.fas.fa-trash
              span.uk-margin-small-left DELETE LINK
        .uk-width-auto
          button(type="submit").uk-button.dtp-button-primary.uk-border-rounded
            span
              i.fas.fa-save
            span.uk-margin-small-left= link ? 'Update Link' : 'Add Link'