extends ../layouts/main
block content

  - var formActionUrl = feed ? `/admin/newsroom/${feed._id}` : '/admin/newsroom';

  form#add-feed-form(method="POST", action= formActionUrl).uk-form

    input(type="hidden", name="generator", value="DTP News")
    input(type="hidden", name="language", value="en")
    input(type="hidden", name="published")

    .uk-card.uk-card-default.uk-card-small
      .uk-card-header
        h1.uk-card-title= feed ? 'Update Feed' : 'Add Feed'
      .uk-card-body
        .uk-margin
          label(for="url").uk-form-label Feed URL
          input(id="url", name="url", type="url", placeholder="Enter feed URL", value= feed ? feed.url : undefined).uk-input
          .uk-margin-small
            button(type="button", onclick="return dtp.adminApp.resolveNewsroomFeed(event);").uk-button.uk-button-default.uk-button-small.uk-border-rounded Resolve Feed
            span.uk-margin-small-left to load the following information automatically.

        .uk-margin
          label(for="title").uk-form-label Title
          input(id="title", name="title", type="text", placeholder="Enter feed title", value= feed ? feed.title : undefined).uk-input

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

        .uk-margin
          label(for="description").uk-form-label Description
          textarea(id="description", name="description", rows="4", placeholder="Enter feed description").uk-textarea.uk-resize-vertical= feed ? feed.description : undefined

      .uk-card-footer
        div(uk-grid).uk-flex-right.uk-flex-middle
          .uk-width-expand
            +renderBackButton()

          if feed
            .uk-width-auto
              button(
                type="button",
                data-feed-id= feed._id,
                data-feed-title= feed.title,
                onclick="return dtp.adminApp.removeNewsroomFeed(event);",
              ).uk-button.uk-button-danger.uk-border-rounded
                span
                  i.fas.fa-trash
                span.uk-margin-small-left Remove Feed

          .uk-width-auto
            button(type="submit").uk-button.uk-button-primary.uk-border-rounded
              span
                i.fas.fa-save
              span.uk-margin-small-left= feed ? 'Update Feed' : 'Add Feed'