gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 412/459: quality of life improvements


From: gnunet
Subject: [reclaim-ui] 412/459: quality of life improvements
Date: Fri, 11 Jun 2021 23:28:24 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.

commit 2af62d70239f368655bee6349ce0013886e83d2e
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jan 5 23:04:39 2021 +0900

    quality of life improvements
---
 .../edit-credentials.component.html                |  2 +-
 src/app/edit-identity/edit-identity.component.html | 21 +++++++----
 src/app/edit-identity/edit-identity.component.ts   |  2 +-
 src/app/identity-list/identity-list.component.html |  7 +++-
 src/app/identity-list/identity-list.component.ts   | 41 ++++++++++++++++------
 src/locales/de/messages.json                       |  1 +
 src/locales/en/messages.json                       |  1 +
 7 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/src/app/edit-credentials/edit-credentials.component.html 
b/src/app/edit-credentials/edit-credentials.component.html
index 77b14a6..c5d7705 100644
--- a/src/app/edit-credentials/edit-credentials.component.html
+++ b/src/app/edit-credentials/edit-credentials.component.html
@@ -42,7 +42,7 @@
           </td>
           <td>
             <button class="btn btn-primary" 
(click)="deleteCredential(credential)">
-              <span class="fa fa-trash"></span>
+              <span class="fa fa-trash"></span> {{ getMessage("Delete") }}
             </button>
           </td>
           <td>
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index a75569d..6a767d8 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -98,9 +98,11 @@
             <div class="col-sm" style="display:flex;">
               <div style="flex:1;">
                 <input *ngIf="!isClaimCred(newRequestedAttribute) && 
!isClaimCredentialRequested(newRequestedAttribute)"
-                   placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="newRequestedAttribute.value">
+                   placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="newRequestedAttribute.value"
+                   (keyup.enter)="canAddAttribute(newRequestedAttribute) && 
saveAttribute(newRequestedAttribute)">
                 <select class="custom-select"
-                        
*ngIf="isClaimCredentialRequested(newRequestedAttribute) && credentials.length 
> 0" (change)="newRequestedAttribute.value=$event.target.value">
+                        
*ngIf="isClaimCredentialRequested(newRequestedAttribute) && credentials.length 
> 0"
+                        
(change)="newRequestedAttribute.value=$event.target.value">
                   <option [value]="getZeroId()" >{{ 
getMessage("edit_identity_html@selectClaim") }}</option>
                   <option *ngFor="let claim of 
credentialValuesForClaim(newRequestedAttribute)" value={{claim.name}}>
                   {{claim.value}} <i>({{claim.name}})</i>
@@ -152,7 +154,8 @@
               </div>
               <div class="col-sm" style="display:flex;">
                 <div style="flex:1;">
-                  <input *ngIf="!isClaimCred(newStandardAttribute)" 
placeholder="{{ getMessage('Value') }}" 
[(ngModel)]="newStandardAttribute.value">
+                  <input *ngIf="!isClaimCred(newStandardAttribute)" 
placeholder="{{ getMessage('Value') }}" [(ngModel)]="newStandardAttribute.value"
+                  (keyup.enter)="canAddAttribute(newStandardAttribute) && 
saveAttribute(newStandardAttribute)">
                   <select class="custom-select"
                           *ngIf="newStandardAttribute.credential !== '' && 
isClaimCred(newStandardAttribute)" 
(change)="newStandardAttribute.value=$event.target.value">
                     <option value="" >{{ 
getMessage("edit_identity_html@selectClaim") }}</option>
@@ -186,11 +189,15 @@
             <div class="row mb-3"
                  [class.alert-danger]="isInConflict(newAttribute)">
               <div class="col-sm">
-                <input [class.text-danger]="!attributeNameValid(newAttribute)" 
placeholder="{{ getMessage('edit_identity_html@name') }}" 
[(ngModel)]="newAttribute.name">
+                <input [class.text-danger]="!attributeNameValid(newAttribute)"
+                placeholder="{{ getMessage('edit_identity_html@name') }}" 
[(ngModel)]="newAttribute.name"
+                (keyup.enter)="canAddAttribute(newAttribute) && 
saveAttribute(newAttribute)">
               </div>
               <div class="col-sm" style="display:flex;">
                 <div style="flex:1;">
-                  <input *ngIf="!isClaimCred(newAttribute)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="newAttribute.value">
+                  <input *ngIf="!isClaimCred(newAttribute)" placeholder="{{ 
getMessage('Value') }}"
+                  [(ngModel)]="newAttribute.value"
+                  (keyup.enter)="canAddAttribute(newAttribute) && 
saveAttribute(newAttribute)">
                   <select class="custom-select"
                           *ngIf="newAttribute.credential !== '' && 
isClaimCred(newAttribute)" (change)="newAttribute.value=$event.target.value">
                     <option value="" >{{ 
getMessage("edit_identity_html@selectClaim") }}</option>
@@ -247,7 +254,9 @@
               </div>
               <div class="col-sm" style="display:flex;">
                 <div style="flex:1;" *ngIf="claim == claimInEdit">
-                  <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}" [(ngModel)]="claim.value">
+                  <input *ngIf="!isClaimCred(claim)" placeholder="{{ 
getMessage('Value') }}"
+                  [(ngModel)]="claim.value"
+                  (keyup.enter)="canUpdateAttribute(claim) && 
saveAttribute(claim)">
                   <select class="custom-select"
                           [(ngModel)]="claim.value"
                           *ngIf="claim.credential !== '' && 
isClaimCred(claim)" (change)="credentialClaimSelected(claim, 
$event.target.value)">
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index 0608f61..1869503 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -153,7 +153,7 @@ export class EditIdentityComponent implements OnInit {
       }
   }
 
-  sortAttributes(attrs: Attribute[]) {
+  private sortAttributes(attrs: Attribute[]) {
     return attrs.sort((a,b) => {
       if (this.getAttributePriority(a) > this.getAttributePriority(b)) {
         return -1;
diff --git a/src/app/identity-list/identity-list.component.html 
b/src/app/identity-list/identity-list.component.html
index a79a1f7..3f951ec 100644
--- a/src/app/identity-list/identity-list.component.html
+++ b/src/app/identity-list/identity-list.component.html
@@ -172,9 +172,14 @@
         </div>
         <button class="btn btn-primary mt-3" (click)="openIdentity = identity"
           *ngIf="(openIdentity != identity) && hasLotsOfAttributes(identity)">
-          <i class="fa fa-expand"></i>
+          <i class="fa fa-angle-down"></i>
           {{ getMessage("identity_list_html@showAll") }}
         </button>
+        <button class="btn btn-primary mt-3" (click)="openIdentity = null"
+          *ngIf="(openIdentity == identity)">
+          <i class="fa fa-angle-up"></i>
+          {{ getMessage("identity_list_html@showLess") }}
+        </button>
       </div>
     </div>
     <div *ngIf="inOpenIdFlow()">
diff --git a/src/app/identity-list/identity-list.component.ts 
b/src/app/identity-list/identity-list.component.ts
index 54ffac4..12d9ade 100644
--- a/src/app/identity-list/identity-list.component.ts
+++ b/src/app/identity-list/identity-list.component.ts
@@ -142,24 +142,43 @@ export class IdentityListComponent implements OnInit {
     return this.oidcService.getClaimDescription(attr);
   }
 
-  sortAttributeByStandardClaims(mylist: string[]) {
-    return function(a1: Attribute, a2: Attribute) {
-      var claimNames = mylist;
-      let idx1 = claimNames.indexOf(a1.name);
-      let idx2 = claimNames.indexOf(a2.name);
-      if ((idx1 == -1) && (idx2 != -1)) { return 1;}
-      if ((idx2 == -1) && (idx1 != -1)) { return -1;}
-      if (idx1 > idx2) {return 1;}
-      if (idx1 < idx2) {return -1;}
+  private sortAttributes(attrs: Attribute[]) {
+    return attrs.sort((a,b) => {
+      if (this.getAttributePriority(a) > this.getAttributePriority(b)) {
+        return -1;
+      }
+      if (this.getAttributePriority(a) < this.getAttributePriority(b)) {
+        return 1;
+      }
+      if (a.name > b.name) {
+        return -1;
+      }
+      if (a.name < b.name) {
+        return 1;
+      }
       return 0;
-    }
+    });
+  }
+
+  private getAttributePriority(attr: Attribute) {
+      if (this.oidcService.isStandardProfileClaim(attr)) {
+        return 5;
+      } else if (this.oidcService.isStandardEmailClaim(attr)) {
+        return 6;
+      } else if (this.oidcService.isStandardAddressClaim(attr)) {
+        return 4;
+      } else if (this.oidcService.isStandardPhoneClaim(attr)) {
+        return 3;
+      } else {
+        return 2;
+      }
   }
 
   private updateAttributes(identity) {
     this.attributes[identity.pubkey] = [];
     this.missingClaims[identity.pubkey] = [];
     this.reclaimService.getAttributes(identity).subscribe(attributes => {
-      this.attributes[identity.pubkey] = 
attributes.sort(this.sortAttributeByStandardClaims(this.oidcService.getStandardClaimNames()));
+      this.attributes[identity.pubkey] = this.sortAttributes(attributes);
       this.updateMissingClaims(identity);
     },
     err => {
diff --git a/src/locales/de/messages.json b/src/locales/de/messages.json
index b390e6c..d64d1c2 100644
--- a/src/locales/de/messages.json
+++ b/src/locales/de/messages.json
@@ -108,6 +108,7 @@
     "identity_list_html@editId": "Identität ändern",
     "identity_list_html@moreAttributes": "… und {{ATTRIBUTENUMBER}} weitere 
Attribute",
     "identity_list_html@showAll": "Zeige alle Attribute",
+    "identity_list_html@showLess": "Zeige weniger Attribute",
     "identity_list_html@shareInfo1": "Teile hervorgehobene Informationen mit",
     "identity_list_html@shareInfo2": "von dieser Identität.",
     "identity_list_html@sharingDisabled": "Teilen nicht möglich",
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index 72b5ec9..9ec97cf 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -108,6 +108,7 @@
     "identity_list_html@editId": "Edit identity",
     "identity_list_html@moreAttributes": "… and {{ATTRIBUTENUMBER}} more 
attributes",
     "identity_list_html@showAll": "Show all attributes",
+    "identity_list_html@showLess": "Show less attributes",
     "identity_list_html@shareInfo1": "Share information marked with",
     "identity_list_html@shareInfo2": "from this identity.",
     "identity_list_html@sharingDisabled": "Sharing disabled",

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]