<!--
    Copyright (c) 2016 VMware, Inc. All Rights Reserved.
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        
        http://www.apache.org/licenses/LICENSE-2.0
        
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<div class="container-fluid container-fluid-custom" element-height ng-controller="SignUpController as vm">
  <modal-dialog modal-title="// vm.modalTitle //" modal-message="// vm.modalMessage //" confirm-only="vm.confirmOnly" action="vm.action()"></modal-dialog>
  <div class="container container-custom" ng-init="vm.targetType = {{.AddNew}}">
    <div class="row extend-height">
	    <div class="section">
		    <h1 class="col-md-12 col-md-offset-2 main-title title-color">
        {{ if eq .AddNew true }}
          // 'add_new_title' | tr //
        {{ else }}
          // 'sign_up' | tr //
        {{ end }}
        </h1>
        <div class="row">
          <div class="col-md-12 col-md-offset-2 main-content">
            <form name="form" class="form-horizontal css-form" novalidate>              
              <div class="form-group">
                <label for="username" class="col-sm-3 control-label">// 'username' | tr //:</label>
                <div class="col-sm-7">
                  <input type="text" class="form-control" id="username" ng-model="user.username" name="uUsername" ng-model-options="{ updateOn: 'blur' }" required maxlength="20" invalid-chars user-exists data-target="username">                 
                  <div class="error-message" ng-messages="(form.$submitted || form.uUsername.$touched) && form.uUsername.$error" >
                    <span ng-message="required">// 'username_is_required' | tr //</span>
                    <span ng-message="maxlength">// 'username_is_too_long' | tr //</span>
                    <span ng-message="invalidChars">// 'username_contains_illegal_chars' | tr //</span>
                    <span ng-message="userExists">// 'username_has_been_taken' | tr //</span>
                  </div>
                </div>
                <div class="col-sm-2">
                  <span class="asterisk">*</span>
                </div>
              </div>
              <div class="form-group">
                <label for="email" class="col-sm-3 control-label">// 'email' | tr //:</label>
                <div class="col-sm-7">
                  <input type="email" class="form-control" id="email" ng-model="user.email" name="uEmail" ng-model-options="{ updateOn: 'blur' }" required user-exists data-target="email" maxlength="50">
                  <div class="error-message" ng-messages="(form.$submitted || form.uEmail.$touched) &&form.uEmail.$error">
                    <span ng-message="required">// 'email_is_required' | tr //</span>
                    <span ng-message="email">// 'email_content_illegal' | tr //</span>
                    <span ng-message="userExists">// 'email_has_been_taken' | tr //</span>
                    <span ng-message="maxlength">// 'email_is_too_long' | tr //</span>
                  </div>
                  <p class="help-block small-size-fonts">// 'email_desc' | tr //</p>
                </div>
                <div class="col-sm-2">
                  <span class="asterisk">*</span>
                </div>
              </div>
              <div class="form-group">
                <label for="fullName" class="col-sm-3 control-label">// 'full_name' | tr //:</label>
                <div class="col-sm-7"> 
                  <input type="text" class="form-control" id="fullName" ng-model="user.fullName" name="uFullName" ng-model-options="{ updateOn: 'blur' }" required maxlength="20" invalid-chars>
                  <div class="error-message" ng-messages="(form.$submitted || form.uFullName.$touched) && form.uFullName.$error">
                    <span ng-message="required">// 'full_name_is_required' | tr //</span>
                    <span ng-message="invalidChars">// 'full_name_contains_illegal_chars' | tr //</span>
                    <span ng-message="maxlength">// 'full_name_is_too_long' | tr //</span>
                  </div>
                  <p class="help-block small-size-fonts">// 'full_name_desc' | tr //</p>
                </div>
                <div class="col-sm-2">
                  <span class="asterisk">*</span>
                </div>
              </div>
              <div class="form-group">
                <label for="password" class="col-sm-3 control-label">// 'password' | tr //:</label>
                <div class="col-sm-7">
                  <input type="password" class="form-control" id="password" ng-model="user.password" name="uPassword" ng-model-options="{ updateOn: 'blur' }" required password>
                  <div class="error-message" ng-messages="(form.$submitted || form.uPassword.$touched) && form.uPassword.$error">
                    <span ng-message="required">// 'password_is_required' | tr //</span>
                    <span ng-message="password">// 'password_is_invalid' | tr //</span>
                  </div>
                  <p class="help-block small-size-fonts">// 'password_desc' | tr //</p>
                </div>
                <div class="col-sm-2">
                  <span class="asterisk">*</span>
                </div>
              </div>
              <div class="form-group">
                <label for="confirmPassword" class="col-sm-3 control-label">// 'confirm_password' | tr //:</label>
                <div class="col-sm-7">
                  <input type="password" class="form-control" id="confirmPassword" ng-model="user.confirmPassword" name="uConfirmPassword" ng-model-options="{ updateOn: 'blur' }" compare-to="user.password">
                  <div class="error-message" ng-messages="(form.$submitted || form.uConfirmPassword.$touched) && form.uConfirmPassword.$error">
                    <span ng-message="compareTo">// 'password_does_not_match' | tr //</span>
                  </div>
                </div>
                <div class="col-sm-2">
                  <span class="asterisk">*</span>
                </div>
              </div>
              <div class="form-group">
                <label for="comments" class="col-sm-3 control-label">// 'comments' | tr //:</label>
                <div class="col-sm-7">
                  <input type="text" class="form-control" id="comments" ng-model="user.comment" name="uComments" ng-model-options="{ updateOn: 'blur' }" maxlength="20">
                  <div class="error-message" ng-messages="(form.$submitted || form.uComments.$touched) && form.uComments.$error">
                    <span ng-show="maxlength">// 'comment_is_too_long' | tr //</span>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <div class="col-md-offset-8 col-md-10">
                  {{ if eq .AddNew true }}
                    <button type="submit" class="btn btn-success" ng-click="form.$valid && vm.signUp(user)">// 'add_new' | tr //</button>                    
                  {{ else }}
                    <button type="submit" class="btn btn-success" ng-click="form.$valid && vm.signUp(user)">// 'sign_up' | tr //</button>                 
                  {{ end }}
                </div>
              </div>  
            </form>
          </div>
        </div>            
      </div>
    </div>
  </div>
</div>