<?xml version='1.0' standalone='yes'?>
<container
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:var="http://www.skyrix.com/od/binding"
    xmlns:const="http://www.skyrix.com/od/constant"
    xmlns:label="OGo:label">
  <md-dialog flex="40" flex-md="60" flex-sm="80" flex-xs="100">
    <md-toolbar>
      <div class="md-toolbar-tools">
        <md-icon class="material-icons sg-icon-toolbar-bg">assignment_turned_in</md-icon>
        <div class="sg-md-title md-flex">
          <!-- classification -->
          <md-icon ng-if="::editor.component.classification == 'confidential'">visibility_off</md-icon>
          <md-icon ng-if="::editor.component.classification == 'private'">vpn_key</md-icon>
          <!-- priority -->
          <md-icon ng-if="::editor.highPriority()">priority_high</md-icon>
          <!-- summary -->
          <span ng-bind="::editor.component.summary"><!-- summary --></span>
        </div>
        <md-menu>
          <md-button label:aria-label="More options" class="sg-icon-button" ng-click="$mdMenu.open($event)">
            <md-icon>more_vert</md-icon>
          </md-button>
          <md-menu-content>
            <md-menu-item>
              <md-button label:aria-label="View Raw Source"
                         ng-click="editor.toggleRawSource($event)">
                <var:string label:value="View Raw Source"/>
              </md-button>
            </md-menu-item>
          </md-menu-content>
        </md-menu>
        <md-button class="sg-icon-button"
                   ng-show="editor.component.status != 'completed'"
                   ng-click="editor.component.markAsCompleted()">
          <md-icon label:aria-label="Mark Completed">check</md-icon>
        </md-button>
        <md-button class="sg-icon-button" ng-click="editor.close()">
          <md-icon label:aria-label="Close">close</md-icon>
        </md-button>
      </div>
    </md-toolbar>
    <md-dialog-content>
      <md-list>
        <!-- categories -->
        <md-list-item ng-show="::(editor.component.categories.length > 0)">
          <md-chips class="sg-readonly" ng-model="::editor.component.categories" readonly="true">
            <md-chip-template>
              <span class="sg-chip-color" style="z-index: 1">
                <span ng-style="{ 'background-color': editor.service.$categories[$chip] }"><!-- color --></span>
              </span>
              <span ng-bind="$chip"><!-- category --></span>
            </md-chip-template>
          </md-chips>
        </md-list-item>
        <!-- location -->
        <md-list-item ng-show="::editor.component.location">
          <md-icon>place</md-icon>
          <p ng-bind-html="::editor.component.location | txt2html"><!-- location --></p>
        </md-list-item>
        <!-- calendar -->
        <md-list-item>
          <md-icon>event</md-icon>
          <div layout="row" layout-align="start center">
            <div class="sg-color-chip"
                 ng-class="::editor.component.getClassName('bg')"><!-- color --></div>
            <div ng-bind="::editor.component.calendar"><!-- calendar --></div>
          </div>
        </md-list-item>
        <!-- start/due dates -->
        <md-list-item ng-class="{ 'md-2-line': editor.component.isAllDay, 'md-3-line': !editor.component.isAllDay }"
                      ng-show="::(editor.component.startDate || editor.component.dueDate)">
          <md-icon>access_time</md-icon>
          <div class="md-list-item-text" ng-show="::editor.component.startDate">
            <label class="pseudo-input-label"><var:string label:value="Start"/></label>
            <div ng-bind="::editor.component.localizedStartDate"><!-- start date --></div>
            <div ng-hide="editor.component.isAllDay" ng-bind="::editor.component.localizedStartTime"><!-- start time --></div>
          </div>
          <div class="md-list-item-text" ng-show="::editor.component.dueDate">
            <label class="pseudo-input-label"><var:string label:value="Due Date"/></label>
            <div ng-bind="::editor.component.localizedDueDate"><!-- due date --></div>
            <div ng-hide="::editor.component.isAllDay" ng-bind="::editor.component.localizedDueTime"><!-- due time --></div>
          </div>
        </md-list-item>
        <!-- status -->
        <md-list-item ng-show="editor.component.status == 'completed'">
          <md-icon>check</md-icon>
          <p>{{editor.component.localizedCompletedDate}} {{editor.component.localizedCompletedTime}}</p>
        </md-list-item>
        <md-list-item ng-show="editor.component.showPercentComplete()">
          <md-icon>timelapse</md-icon>
          <p>{{editor.component.percentComplete}} %</p>
        </md-list-item>
        <md-list-item ng-show="editor.component.status == 'cancelled'">
          <md-icon>close</md-icon>
          <p><var:string label:value="status_CANCELLED"/></p>
        </md-list-item>
        <md-list-item ng-show="editor.component.status == 'needs-action'">
          <md-icon>error_outline</md-icon>
          <p><var:string label:value="status_NEEDS-ACTION"/></p>
        </md-list-item>
        <!-- attach urls -->
        <md-list-item  ng-repeat="url in ::editor.component.attachUrls">
          <md-icon>link</md-icon>
          <p><a ng-href="{{::url.value}}" rel="noopener" target="_new" ng-bind="::url.value"><!-- link --></a></p>
        </md-list-item>
        <!-- comment -->
        <md-list-item ng-show="::editor.component.comment">
          <md-icon>mode_comment</md-icon>
          <p ng-bind-html="::editor.component.comment | txt2html"><!-- comment --></p>
        </md-list-item>
        <!-- repeat -->
        <md-list-item ng-show="::editor.component.$isRecurrent">
          <md-icon>repeat</md-icon>
          <p ng-bind="::editor.component.repeatDescription()"><!-- repeat --></p>
        </md-list-item>
        <!-- reminder -->
        <md-list-item ng-show="::editor.component.$hasAlarm">
          <md-icon>alarm_on</md-icon>
          <p ng-bind="::editor.component.alarmDescription()"><!-- alarm --></p>
        </md-list-item>
      </md-list>
    </md-dialog-content>

    <!-- actions -->

    <!-- editable but not recurrent -->
    <md-dialog-actions ng-show="::editor.component.isActionable()">
      <md-button class="md-warn" label:aria-label="Delete Task"
                 ng-show="::editor.component.isErasable"
                 ng-click="editor.deleteAllOccurrences()">
        <var:string label:value="Delete"/>
      </md-button>
      <div class="md-flex"><!-- spacer --></div>
      <md-button type="button"
                 ng-show="::editor.component.isEditable"
                 ng-click="editor.edit()">
        <var:string label:value="Edit"/>
      </md-button>
    </md-dialog-actions>
    <!-- editable and recurrent -->
    <md-dialog-actions ng-show="::editor.component.isActionableOccurrence()">
      <md-menu ng-show="::editor.component.isErasable">
        <md-button class="md-warn"
                   label:aria-label="Delete Task"
                   ng-click="$mdMenu.open()"
                   md-menu-origin="md-menu-origin">
          <var:string label:value="Delete"/> <md-icon>arrow_drop_down</md-icon>
        </md-button>
        <md-menu-content>
          <md-menu-item>
            <md-button class="md-warn"
                       label:aria-label="Delete This Occurrence"
                       ng-click="editor.deleteOccurrence()">
              <md-icon>repeat_one</md-icon> <var:string label:value="Delete This Occurrence"/>
            </md-button>
          </md-menu-item>
          <md-menu-item>
            <md-button class="md-warn"
                       label:aria-label="Delete All Occurrences"
                       ng-click="editor.deleteAllOccurrences()">
              <md-icon>repeat</md-icon> <var:string label:value="Delete All Occurrences"/>
            </md-button>
          </md-menu-item>
        </md-menu-content>
      </md-menu>
      <div class="md-flex"><!-- spacer --></div>
      <md-menu ng-show="::editor.component.isEditable">
        <md-button label:aria-label="Edit"
                   ng-click="$mdMenu.open()"
                   md-menu-origin="md-menu-origin">
          <var:string label:value="Edit"/> <md-icon>arrow_drop_down</md-icon>
        </md-button>
        <md-menu-content>
          <md-menu-item>
            <md-button type="button" label:aria-label="Edit This Occurrence"
                       ng-click="editor.edit()">
              <md-icon>repeat_one</md-icon> <var:string label:value="Edit This Occurrence"/>
            </md-button>
          </md-menu-item>
          <md-menu-item>
            <md-button type="button" label:aria-label="Edit All Occurrences"
                       ng-click="editor.editAllOccurrences()">
              <md-icon>repeat</md-icon> <var:string label:value="Edit All Occurrences"/>
            </md-button>
          </md-menu-item>
        </md-menu-content>
      </md-menu>
    </md-dialog-actions>
  </md-dialog>
</container>
