extends /layout

mixin sideMenu(meta)
  include /common/side-menu-mixin-consultancy
  +sideNavigation(meta)

block pageSpecificScipts
  script(nonce=cspNonce src="/javascripts/utils.js")
  script(nonce=cspNonce src="/javascripts/mixed-content.js")
  script(nonce=cspNonce src="/javascripts/consultancy.js")
  script(nonce=cspNonce src="/javascripts/consultancy-edit.js")
  script(nonce=cspNonce src="/javascripts/comments.js")
  script(nonce=cspNonce src="/javascripts/consultancy-handle-unsaved.js")

block body
  - const specificUserRights = user && (user.hasRole('consultant') || user.hasRole('consultancy admin'))
  section#fixed-top-section
    include /common/main-navigation
    +main-navigation(false)
  block config
    - const pageTypeObject = sentFrom
    - const subHeading = t('Urejanje')
    - const description = t('Dodajte terminološki odgovor in ga utemeljite.')

  +sideMenu(pageTypeObject)

  include ../../../utilities/mixed-content

  include /utilities/consultancy-admin-in-progress-panel-header
  //- const c = { h1: 'Terminološko svetovanje', description: 'Terminološka svetovalnica je namenjena širši strokovni javnosti, ki se sooča s konkretnimi poimenovalnimi problemi, pa naj gre za popolnoma nove pojme, ki jih je v slovenščini šele treba poimenovati, ali že znane pojme, za katere obstaja več poimenovanj, pa strokovnjaki čutijo potrebo po sistemskem poenotenju oz. izbiri najprimernejše rešitve.', buttons: [{ type: 'link', content: 'Zastavi novo vprašanje', url: '/svetovanje/vprasanje/novo' }] }
  - const c = { noSidebar: true, hrefurl: `/svetovanje/vprasanje/admin/${sentFrom}`, specificRights: specificUserRights, exportButtonPresent: false, h1: t('Urejanje terminološkega odgovora'), description: t('Dodajte terminološki odgovor in ga utemeljite.'), buttons: [{ form: 'edit-form', type: 'button', content: t('Shrani'), contentDisabled: true }] }
  +mainHeader(c)
  if specificUserRights
    .content-hold-prerequisites
      #offset-main.main-container.offset-correction
        .row.mt-4.mx-0
          .col.g-0
            p.text-header-description-gray.mb-2 <b>#{ t('Datum vprašanja:') }</b> #{ entry.timeCreated }
            p.text-header-description-gray.mt-2.mb-0 <b>#{ t('Uporabnik') }:</b> #{ author.firstName }
            p.text-header-description-gray.mt-1 <b>#{ t('E-pošta') }:</b> #{ author.email }
            hr
            p.text-header-description-gray.mb-2 <b>#{ t('Datum objave/spremembe') }:</b> #{ entry.timePublished }
            p.text-header-description-gray.mt-2.mb-0 <b>#{ t('Avtorji mnenja:') }</b>
              span.text-header-description-gray= ` ${entry.answerAuthors ? entry.answerAuthors.join(`, `) : ''}`
            p.text-header-description-gray.mt-1 <b>#{ t('URL povezava do mnenja:') }</b> #{ isPublished?`${urlPrefix}/svetovanje/vprasanje/${id}`:'' }
            hr
        form#edit-form.row(method="put" action="/api/v1/consultancy/entry")
          input(type="hidden" name="_method" value="put")
          input#entry-id.d-none(type="text" value=id)
          .col
            h5.navigation-text-color #{ t('Urejanje') }

            #question-title-field.mt-4
              .title.mt-4
                .subject-name.col.d-flex.justify-content-between
                  label.mb-1.smaller-gray-uppercase(for="address") #{ t('NASLOV') }*
                  - const type = 'two'
                  +mixedContentBtns
                .row
                  .col
                    textarea#question-title.form-control.explanation-field.mc-field.dispatch-tab(
                      type="text"
                      name="address"
                    ) #{ entry.title }
                //- .col-sm.d-flex.align-items-center
                  span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3 Navodilo k posamičnemu polju. Reprehenderit aliqua quis ut velit eu irure non ad sunt sunt ipsum sunt esse.

            .cerif-area.mt-4
              .subject-name
                label.smaller-gray-uppercase(for="select-cerif") #{ t('PODROČJE') }
              .row
                #cerif
                  select#select-cerif.select-cerif.name-input.d-inline.form-control(
                    name="domainPrimary"
                    required
                  )
                    option(value=-1)
                    each domain in allPrimaryDomains
                      option(
                        value=domain.id
                        selected=domain.id === entry.domainPrimaryId
                      )= domain.name
                #invalid-section.invalid-feedback-selection.hidden-section.mt-3 #{ t('Nimate izbranega področja CERIF.') }
                //- .col-sm.d-flex.align-items-center
                  span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3 Področje, v katero sodi opisani terminološki problem

            #question-field.mt-4
              .title.mt-4
                .subject-name.col.d-flex.justify-content-between
                  label.mb-1.smaller-gray-uppercase(for="questionTitle") #{ t('VPRAŠANJE') }*
                  +mixedContentBtns(type)
                .row
                  .col
                    textarea#question.form-control.explanation-field.mc-field.dispatch-tab(
                      type="text"
                      name="questionTitle"
                    ) #{ entry.question }
                //- .col-sm.d-flex.align-items-center
                  span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3 Navodilo k posamičnemu polju. Reprehenderit aliqua quis ut velit eu irure non ad sunt sunt ipsum sunt esse.

              #text-editor.mt-4
                .subject-name
                  span.smaller-gray-uppercase #{ t('MNENJE') }*
                .row
                  .col
                    -
                      let innerHTML = ""
                      if(!!entry.answer){
                        innerHTML = entry.answer
                      } else {
                      if(entry.institution){
                        innerHTML +=  `
                        <b>${t('Institucija')}:</b> ${entry.institution}
                        <br><br>
                        `
                        }
                        if(entry.description){
                        innerHTML += `
                        <b>${t('Opis terminološkega problema')}:</b> ${entry.description}
                        <br><br>`
                        }
                        if(entry.existingSolutions){
                        innerHTML += `
                        <b>${t('Obstoječe poimenovalne rešitve')}:</b> ${entry.existingSolutions}
                        <br><br>
                        `
                        }
                        if(entry.examplesOfUse){
                        innerHTML += `
                        <b>${t('Primeri rabe')}:</b> ${entry.examplesOfUse}
                        <br><br><br>
                        `
                        }
                      }

                    #opinion.summernote !{ innerHTML }
                  //- .col-sm.d-flex.align-items-center
                    span.d-md-inline.d-block.smaller-gray-info.ms-xxl-3.ms-md-3 Navodilo k posamičnemu polju. Reprehenderit aliqua quis ut velit eu irure non ad sunt sunt ipsum sunt esse.
        .comments-content.col-12.col-md-12.pt-md-3.bd-content
          include /utilities/comments-with-pager
        include /common/footer
  else
    include /utilities/empty-main-panel-header
    +mainHeader
    .content-hold-prerequisites.ps-4.pe-4
      #offset-main.ps-2.pe-2
        p #{ t('Nimate ustreznih pravic') }
  include /utilities/modal-alert-mixin
  +alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', t('Imate neshranjene spremebe. Ali jih želite shraniti?'))
