template(name="cardCustomFieldsPopup")
    ul.pop-over-list
        each board.customFields
            li.item(class="")
                a.name.js-select-field(href="#")
                    span.full-name
                      = name
                    if hasCustomField
                      i.fa.fa-check
    hr
    a.quiet-button.full.js-settings
        i.fa.fa-cog
        span {{_ 'settings'}}

template(name="cardCustomField")
    +Template.dynamic(template=getTemplate)

template(name="cardCustomField-text")
    if canModifyCard
        +inlinedForm(classNames="js-card-customfield-text")
            +editor(autofocus=true)
                = value
            .edit-controls.clearfix
                button.primary(type="submit") {{_ 'save'}}
                a.fa.fa-times-thin.js-close-inlined-form
        else
            a.js-open-inlined-form
                if value
                    +viewer
                        = value
                else
                    | {{_ 'edit'}}
    else
      +viewer
        = value


template(name="cardCustomField-number")
    if canModifyCard
        +inlinedForm(classNames="js-card-customfield-number")
            input(type="number" value=data.value)
            .edit-controls.clearfix
                button.primary(type="submit") {{_ 'save'}}
                a.fa.fa-times-thin.js-close-inlined-form
        else
            a.js-open-inlined-form
                if value
                    = value
                else
                    | {{_ 'edit'}}
    else
        if value
            = value

template(name="cardCustomField-checkbox")
  .js-checklist-item.checklist-item(class="{{#if data.value }}is-checked{{/if}}")
    if canModifyCard
      .check-box-container
        .check-box.materialCheckBox(class="{{#if data.value }}is-checked{{/if}}")
    else
      .materialCheckBox(class="{{#if data.value }}is-checked{{/if}}")

template(name="cardCustomField-currency")
    if canModifyCard
        +inlinedForm(classNames="js-card-customfield-currency")
            input(type="text" value=data.value autofocus)
            .edit-controls.clearfix
                button.primary(type="submit") {{_ 'save'}}
                a.fa.fa-times-thin.js-close-inlined-form
        else
            a.js-open-inlined-form
                if value
                    = formattedValue
                else
                    | {{_ 'edit'}}
    else
        if value
            = formattedValue

template(name="cardCustomField-date")
    if canModifyCard
      a.js-edit-date(title="{{showTitle}} {{_ 'predicate-week'}} {{showWeek}}" class="{{classes}}")
        if value
          div.card-date
            time(datetime="{{showISODate}}")
              | {{showDate}}
              b
                | {{showWeek}}
        else
          | {{_ 'edit'}}
    else
      if value
        div.card-date
          time(datetime="{{showISODate}}")
            | {{showDate}}
            b
              | {{showWeek}}

template(name="cardCustomField-dropdown")
    if canModifyCard
        +inlinedForm(classNames="js-card-customfield-dropdown")
            select.inline
                each items
                    if($eq data.value this._id)
                        option(value=_id selected="selected")
                          +viewer
                            = name
                    else
                        option(value=_id)
                          +viewer
                            = name
            .edit-controls.clearfix
                button.primary(type="submit") {{_ 'save'}}
                a.fa.fa-times-thin.js-close-inlined-form
        else
            a.js-open-inlined-form
                if value
                    +viewer
                        = selectedItem
                else
                    | {{_ 'edit'}}
    else
        if value
            +viewer
                = selectedItem

template(name="cardCustomField-stringtemplate")
    if canModifyCard
        +inlinedForm(classNames="js-card-customfield-stringtemplate")
            each item in stringtemplateItems.get
                input.js-card-customfield-stringtemplate-item(type="text" value=item placeholder="")
            input.js-card-customfield-stringtemplate-item.last(type="text" value="" placeholder="{{_ 'custom-field-stringtemplate-item-placeholder'}}" autofocus)
            .edit-controls.clearfix
                button.primary(type="submit") {{_ 'save'}}
                a.fa.fa-times-thin.js-close-inlined-form
        else
            a.js-open-inlined-form
                if value
                    +viewer
                        = formattedValue
                else
                    | {{_ 'edit'}}
    else
        if value
            +viewer
                = formattedValue
