<ion-view view-title="{{'Travel' | translate}}">
  <ion-content>
    <div class="item item-avatar">
        <img ng-src="img/{{travel.modality}}.png" />
        <div class="item-note o-text-right">
          <p>
            <a class="o-badge-calm" href="#/app/users/{{travel.owner}}">{{travel.owner}}</a>
          </p>
            <p ng-show="storageusername==travel.owner" class="text-right">
                <a href="#" ng-click="deleteTravel()" class="button button-small button-assertive o-pull-right"><i class="icon ion-trash-a"></i></a>
            </p>
        </div>
        <h2>{{travel.title}}</h2>
        <div class="">{{travel.date | date:"dd/MM HH:mm a"}}</div>
    </div>
    <div class="item item-body">
      <div class='row'>

          <p class="o-bold">{{travel.description}}</p>
      </div>
      <div class='row'>
        <div class='col'>
          <p ng-show="travel.phone">
              <img class='o-imgMenu' src="img/smartphone.png" /> {{travel.phone}}
          </p>
          <p ng-show="travel.telegram">
              <img class='o-imgMenu' src="img/telegram.png" /> @{{travel.telegram}}
          </p>

          <p><img class='o-imgTitle' src="img/from-to.png" />{{travel.from}} - {{travel.to}}</p>
        </div>
        <div class='col o-text-right'>
          <p ng-show="travel.collectivized">
            <span class="o-badgeCollectivized">{{'Collectivized' | translate}}</span>
          </p>
          <p ng-show="travel.package">
            <div class="o-mini-text">
                <div ng-show="travel.modality=='offering'">{{'Can_carry_package' | translate}} <img src="img/package.png" class="o-imgMenu" /></div>
                <div ng-show="travel.modality=='asking'">{{'Need_to_carry_package' | translate}} <img src="img/package.png" class="o-imgMenu" /></div>
            </div>
          </p>

            <p>
                <div ng-show="travel.modality=='offering'">{{'n_Seats' | translate}}: {{travel.seats}}</div>
                <div ng-show="travel.modality=='asking'">{{'n_People' | translate}}: {{travel.seats}}</div>
            </p>
        </div>
      </div>
        <br>


        <div ng-show="storageusername">
            <p class='text-right' ng-show="storageusername!=travel.owner">
              <div ng-show="arrayObjectIndexOf(joins, storageusername, 'joinedUsername')==-1">
                <a ng-show="travel.modality=='offering'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">{{'Ask_to_join' | translate}}</a>
                <a ng-show="travel.modality=='asking'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">{{'Offer_car' | translate}}</a>
                <a ng-show="travel.modality=='package'" ng-click="joinTravel()" href="#" class="button button-calm o-pull-right">{{'Offer_car' | translate}}</a>
              </div>

              <div ng-show="arrayObjectIndexOf(joins, storageusername, 'joinedUsername')!=-1">
                <a ng-show="travel.modality=='offering'" ng-click="unjoinTravel()" href="#" class="button button-assertive o-pull-right">{{'Unjoin' | translate}}</a>
                <a ng-show="travel.modality=='asking'" ng-click="unjoinTravel()" href="#" class="button button-assertive o-pull-right">{{'Unoffer_car' | translate}}</a>
                <a ng-show="travel.modality=='package'" ng-click="unjoinTravel()" href="#" class="button button-assertive o-pull-right">{{'Unoffer_car' | translate}}</a>
              </div>
            </p>
        </div>
    </div>
    <div class="item item-body" ng-show="joins[0]">
        {{'Joined_users' | translate}}:<br>
        <a ng-repeat="join in joins" ng-href="#/app/users/{{join.joinedUsername}}" class="button button-small button-dark">
            <img ng-src="img/avatars/{{join.joinedAvatar}}.png" class="o-img-joined" />{{join.joinedUsername}}<br>
        </a>
    </div>
    <div class="item item-body">
        <div ng-show="comments[0]">
            {{'Comments' | translate}}:<br>
            <a ng-repeat="comment in comments" ng-href="#/app/users/{{comment.commentUsername}}" class="item">
                <h3><img ng-src="img/avatars/{{comment.commentAvatar}}.png" class="o-img-joined" />{{comment.commentUsername}}</h3>
                <p>{{comment.comment}}</p>
            </a>
        </div>
        <div ng-show="storageusername">
          <a ng-click="showNewComment()" ng-show="!doingNewComment" class="button button-small button-calm right">{{'New_comment' | translate}}</a>
        </div>
        <form class="list" ng-show="doingNewComment">
            <label class="item item-input item-floating-label">
                <input ng-model="newComment.comment" type="text" placeholder="Comment">
            </label>

            <button ng-click="closeNewComment()" class="button button-small button-assertive">
               {{'Cancel' | translate}}
            </button>
            <button ng-click="doNewComment()" class="button button-small button-calm">
               {{'Post_comment' | translate}}
            </button>
        </form>
    </div>
  </ion-content>
</ion-view>
