<div class="uk-child-width-expand@s uk-text-center uk-margin-bottom" uk-grid>
  <div>
    <form class=" uk-animation uk-card uk-card-default uk-padding" >
      <div>
        <select class="uk-select"  [(ngModel)]="selectedFunderId" name="select_funder"  >
         <option  value="0" (click)="funderChanged('0','Select funder:')">Select funder:</option>
         <option *ngFor="let  funder of funders"  [value]="funder.id" (click)="funderChanged(funder.id,funder.name)">{{(funder.name.split("||").length > 0)?(funder.name.split("||")[0]+" ("+funder.name.split("||")[1]+")"):(funder.name)}}</option>
        </select>
      </div>
    </form>
  </div>
  <div>
    <form class="uk-text-center uk-animation uk-card uk-card-default uk-padding">
      <div>
        <input type="text" class="uk-input  uk-width-1-2" placeholder="Project name or ID" aria-describedby="sizing-addon2"  [(ngModel)]="openaireSearchUtils.keyword"  name="keyword" >
        <button (click)="keywordChanged(openaireSearchUtils.keyword)"  type="submit" class=" uk-button">
           <span class="uk-icon">
           <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg>
           </span>Search
         </button>
      </div>
    </form>
  </div>
</div>

<div *ngIf="openaireSearchUtils.status == errorCodes.DONE" class="uk-alert uk-alert-primary">
  <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>
Newly added projects will be linked to your community on the next run of our algorithms.
<!-- <div> If you cannot find a funder that is relevant for your community, please contact us (<a [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing Funder' + '&body=' + body" target="_top">feedback@openaire.eu</a>) and we'll try to get the funder on board!</div> -->


</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.DONE" class="uk-alert uk-alert-primary">
  <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>
If you cannot find a funder that is relevant for your community, please contact us (<a [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing Funder' + '&body=' + body" target="_top">feedback@openaire.eu</a>) and we'll try to get the funder on board!


</div>

<errorMessages [status]="[openaireSearchUtils.status]" [type]="'OpenAIRE projects'"></errorMessages>
<div *ngIf="openaireSearchUtils.status == errorCodes.NONE" class="uk-alert uk-alert-primary">
  <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>
   If you wish to suggest a new funder to include or report a missing project, please contact us via
   <a [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing project' + '&body=' + body" target="_top">feedback@openaire.eu</a>.
</div>

<div *ngIf="openaireSearchUtils.totalResults > 0" class="uk-align-center uk-margin-remove-bottom">
  <div class="searchPaging uk-panel uk-margin-top uk-grid uk-margin-bottom">
    <span class="uk-h6 uk-width-1-1@s uk-width-1-2@m">
      {{openaireSearchUtils.totalResults | number}} projects, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}}
    </span>
    <span class="float-children-right-at-medium margin-small-top-at-small uk-width-1-1@s uk-width-1-2@m">
      <paging-no-load [limitPaging]=true [currentPage]="openaireSearchUtils.page" [totalResults]="openaireSearchUtils.totalResults" [size]="rowsOnPage" (pageChange)="goTo($event.value)"></paging-no-load>
    </span>
  </div>
</div>

<ul *ngIf="(openaireSearchUtils.page <= pagingLimit)" [class]="'uk-list uk-list-divider  uk-margin '+custom_class">
 <!-- <errorMessages [status]="[status]" [type]="'results'"></errorMessages> -->

   <li *ngFor="let result of openaireProjects" class="uk-animation-fade">
       <h6 class="uk-grid" uk-grid>
           <span class="uk-width-5-6">
             <a class="custom-external" target="_blank" [href]="properties.baseOpenaireLink+'/search/project?projectId='+result.id">
               <span *ngIf="result['title'].name || result.acronym">
                 <span *ngIf="result.acronym">{{result.acronym}}</span>
                 <span *ngIf="result.acronym && result['title'].name">-</span>
                 <span [innerHTML]="result['title'].name"></span>
                 <span *ngIf="result.code">({{result.code}})</span>
               </span>
               <span *ngIf="!result['title'].name && !result.acronym">
                 [no title available]
                 <span *ngIf="result.code">({{result.code}})</span>
              </span>
             </a>
           </span>

           <span class="uk-width-1-6 uk-text-center">
             <!-- <a *ngIf="!inCommunity(result)" (click)="addProject(result)" class="uk-icon-button"><svg height="20" icon="plus" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><rect height="17" width="1" x="9" y="1"></rect><rect height="1" width="17" x="1" y="9"></rect></svg></a> -->
<!--               green_background_color green_color-->
             <a *ngIf="!inCommunity(result)" (click)="addProject(result)" class="uk-icon-button add uk-button-primary" uk-icon="plus" title="Add"></a>

             <span *ngIf="inCommunity(result)" class="uk-label uk-label-success">Added</span>
             <!-- <svg *ngIf="inCommunity(result)" class="added" src="assets/imgs/check-icon.png" title="Added" width="20" type="image" height="20"></svg> -->

             <!-- <button *ngIf="undo[result.id]" class="uk-button uk-button-danger uk-button-small" (click)="removeProject(result.id)">Undo</button> -->
             <!-- <input *ngIf="undo[result.id]" (click)="removeProject(result.id)" class="remove" src="assets/imgs/x-icon.png" title="Undo" width="20" type="image" height="20"> -->
             <!-- <a *ngIf="undo[result.id]" (click)="removeProject(result.id)" class="remove red_colour"><svg height="20" icon="close" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><rect height="17" width="1" x="9" y="1"></rect><rect height="1" width="17" x="1" y="9"></rect></svg></a> -->
<!--               red_background_color red_color-->
             <a *ngIf="undo[result.id]" (click)="removeProject(undo[result.id], result.id)" class="uk-icon-button remove uk-button-danger" uk-icon="close" title="Undo"></a>

          </span>
       </h6>
       <span *ngIf="result.title && result.title.accessMode" [class]="'uk-label custom-label  label-'+ result.title.accessMode " title="Access Mode">{{result.title.accessMode}}</span>
       <span *ngIf="result.funderShortname" class="uk-label custom-label label-funder " title="Funder">{{result.funderShortname}}</span>
       <span *ngIf="result.title  && result.title.sc39" class="uk-label custom-label label-sc39 " title="Special Clause 39">Special Clause 39</span>

       <div *ngIf="result.startYear && result.endYear"> Start year: {{result.startYear}} - End year: {{result.endYear}}</div>
       <div *ngIf="result['organizations'] != undefined && result['organizations'].length > 0">
           <span> Organization: </span>
           <span *ngFor="let organization of result['organizations'].slice(0,10) let i=index">
               <a *ngIf="organization.id" class="custom-external custom-icon" target="_blank"
                  [href]="properties.baseOpenaireLink+'/search/organization?organizationId='+organization.id">
                       {{organization.name}}</a><span

                   *ngIf="!organization.id">
                       {{organization.name}}</span><span

                   *ngIf="(i < result['organizations'].length-1) && (i < 9)">,</span>
           </span>
           <span *ngIf="result['organizations'].length > 10">...</span>
       </div>
   </li>
</ul>

<div [class]="openaireSearchUtils.page > pagingLimit ? 'search-results' : ''" *ngIf="(openaireSearchUtils.page >= pagingLimit) && (openaireSearchUtils.totalResults > resultsPerPage*pagingLimit)">
    <p class="uk-alert-warning" uk-alert>For more results please try a new, more specific query</p>
</div>

<div *ngIf="openaireSearchUtils.totalResults > 0" class="uk-align-center uk-margin-remove-bottom">
  <div class="searchPaging uk-panel uk-margin-top uk-grid uk-margin-bottom">
    <span class="uk-h6 uk-width-1-1@s uk-width-1-2@m">
      {{openaireSearchUtils.totalResults | number}} projects, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}}
    </span>
    <span class="float-children-right-at-medium margin-small-top-at-small uk-width-1-1@s uk-width-1-2@m">
      <paging-no-load [limitPaging]=true [currentPage]="openaireSearchUtils.page" [totalResults]="openaireSearchUtils.totalResults" [size]="rowsOnPage" (pageChange)="goTo($event.value)"></paging-no-load>
    </span>
  </div>
</div>
