@angular/common#KeyValue TypeScript Examples

The following examples show how to use @angular/common#KeyValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: new.component.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
reject(id: number) {
    this.overlay.alert({
      header: '拒绝申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.friendRequestReject(id, data['rejectReason']);
      },
      inputs: [{
        name: 'rejectReason',
        type: 'textarea',
        placeholder: '或许可以告诉对方你拒绝的原因',
        cssClass: 'ipt-primary',
        attributes: {
          rows: 4,
          maxlength: REASON_MAX_LENGTH
        }
      }]
    });
  }
Example #2
Source File: new.component.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
agree(id: number, event: Event) {
    event.preventDefault();
    event.stopPropagation();

    this.overlay.alert({
      header: '同意申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.friendRequestAgree(id, data['requesterAlias']);
      },
      inputs: [{
        name: 'requesterAlias',
        type: 'text',
        placeholder: '顺便给对方起个好听的别名吧',
        cssClass: 'ipt-primary',
        attributes: {
          maxlength: NICKNAME_MAX_LENGTH
        }
      }]
    });
  }
Example #3
Source File: handle.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
reject() {
    this.overlay.alert({
      header: '拒绝申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.friendRequestReject(this.request.id, data['rejectReason']);
      },
      inputs: [{
        name: 'rejectReason',
        type: 'textarea',
        placeholder: '或许可以告诉对方你拒绝的原因',
        cssClass: 'ipt-primary',
        attributes: {
          rows: 4,
          maxlength: REASON_MAX_LENGTH
        }
      }]
    });
  }
Example #4
Source File: handle.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
agree() {
    this.overlay.alert({
      header: '同意申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.friendRequestAgree(this.request.id, data['requesterAlias']);
      },
      inputs: [{
        name: 'requesterAlias',
        type: 'text',
        placeholder: '顺便给对方起个好听的别名吧',
        cssClass: 'ipt-primary',
        attributes: {
          maxlength: NICKNAME_MAX_LENGTH
        }
      }]
    });
  }
Example #5
Source File: chat.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
/**
   * 设置好友别名
   */
  setFriendAlias() {
    // 只有私聊才可改好友别名
    if (this.chatroomType !== ChatroomType.Private) { return; }

    this.overlay.alert({
      header: '好友别名',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        if (data['alias'] === this.chatroomName) { return; }

        this.friendService.setAlias(this.chatroomId, data['alias']).subscribe(({ code, data, msg }: Result<string>) => {
          this.chatroomName = data;
          this.overlay.toast('成功修改好友别名!', 1000);

          const chatSession = this.globalData.chatSessions.find(o => o.data.chatroomId === this.chatroomId);
          if (chatSession) {
            chatSession.title = data;
          }
        });
      },
      inputs: [{
        name: 'alias',
        type: 'text',
        value: this.chatroomName,
        placeholder: '给对方起个好听的别名吧',
        cssClass: 'ipt-primary',
        attributes: {
          maxlength: NICKNAME_MAX_LENGTH
        }
      }]
    });
  }
Example #6
Source File: handle.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
reject() {
    this.overlay.alert({
      header: '拒绝申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.chatRequestReject(this.request.id, data['rejectReason'] || null);
      },
      inputs: [{
        name: 'rejectReason',
        type: 'textarea',
        placeholder: '或许可以告诉对方你拒绝的原因',
        cssClass: 'ipt-primary',
        attributes: {
          rows: 4,
          maxlength: REASON_MAX_LENGTH
        }
      }]
    });
  }
Example #7
Source File: home.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
changeChatroomName() {
    this.overlay.alert({
      header: '聊天室名称',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        const { id, name } = this.chatroom;
        if (!StrUtils.trimAll(data['name']).length || data['name'] === name) { return; }

        this.chatroomService.setName(id, data['name']).subscribe(() => {
          this.chatroom.name = data['name'];
          this.overlay.toast('成功修改聊天室名称!', 1000);
          this.cacheService.revoke('/chatroom/' + id);

          const chatSession = this.globalData.chatSessions.find(o => o.data.chatroomId === id);
          if (chatSession) {
            chatSession.title = data['name'];
          }
        });
      },
      inputs: [{
        name: 'name',
        type: 'text',
        value: this.chatroom.name,
        placeholder: '聊天室名称',
        cssClass: 'ipt-primary',
        attributes: {
          maxlength: CHATROOM_NAME_MAX_LENGTH,
          required: true
        }
      }]
    });
  }
Example #8
Source File: home.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
changeNickname() {
    this.overlay.alert({
      header: '我的昵称',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        if (data['nickname'] === this.member.nickname) { return; }

        this.chatroomService.setMemberNickname(this.chatroom.id, data['nickname']).subscribe(({ data }: Result<string>) => {
          const member = this.members.find(o => o.userId === this.globalData.user.id);
          member.nickname = data;
          this.member.nickname = data;
          this.overlay.toast('成功修改我的昵称!', 1000);
          this.cacheService.revoke('/chatroom/' + this.chatroom.id + '/members');
        });
      },
      inputs: [{
        name: 'nickname',
        type: 'text',
        value: this.member.nickname,
        placeholder: '我的昵称',
        cssClass: 'ipt-primary',
        attributes: {
          maxlength: NICKNAME_MAX_LENGTH,
          required: true
        }
      }]
    });
  }
Example #9
Source File: home.page.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
/**
   * 申请加入群聊
   */
  request() {
    this.overlay.alert({
      header: '申请加入',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.chatRequset(this.chatroom.id, StrUtils.trimAll(data['reason']).length ? data['reason'] : undefined);
      },
      inputs: [
        {
          name: 'reason',
          type: 'textarea',
          placeholder: '可以告诉他们你的申请原因',
          cssClass: 'ipt-primary',
          attributes: {
            rows: 4,
            maxlength: REASON_MAX_LENGTH
          }
        }
      ]
    });
  }
Example #10
Source File: notice-list.component.ts    From onchat-web with Apache License 2.0 6 votes vote down vote up
rejectChatRequest(requestId: number) {
    this.overlay.alert({
      header: '拒绝申请',
      confirmHandler: (data: KeyValue<string, SafeAny>) => {
        this.socket.chatRequestReject(requestId, data['rejectReason']);
      },
      inputs: [
        {
          name: 'rejectReason',
          type: 'textarea',
          placeholder: '或许可以告诉对方你拒绝的原因',
          cssClass: 'ipt-primary',
          attributes: {
            rows: 4,
            maxlength: 50
          }
        }
      ]
    });
  }
Example #11
Source File: edit-alert.ts    From sba-angular with MIT License 5 votes vote down vote up
// Preserve original property order
    originalOrder = (a: KeyValue<string, Alert.Days>, b: KeyValue<string, Alert.Days>): number => 0
Example #12
Source File: dependent-intentions.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
public trackByApplicationFn(index: number, entry: KeyValue<string, Intention[]>): string {
    return entry.key;
  }
Example #13
Source File: capture-tab.component.ts    From capture-lite with GNU General Public License v3.0 5 votes vote down vote up
// eslint-disable-next-line class-methods-use-this
  keyDescendingOrder(
    a: KeyValue<string, Proof[]>,
    b: KeyValue<string, Proof[]>
  ): number {
    return a.key > b.key ? -1 : b.key > a.key ? 1 : 0;
  }
Example #14
Source File: fy-view-report-info.component.ts    From fyle-mobile-app with MIT License 5 votes vote down vote up
originalOrder = (a: KeyValue<string, any>, b: KeyValue<string, any>): number => 0;
Example #15
Source File: json-schema-form.component.ts    From json-schema-form with Apache License 2.0 5 votes vote down vote up
/**
   * angular pipe sorting function for keyValue - keep the JSON order and do not
   * order alphabetically
   */
  originalOrder = (a: KeyValue<string, Schema>, b: KeyValue<string, Schema>): number => {
    return 0;
  }
Example #16
Source File: required-capabilities.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
public trackByApplicationFn(index: number, entry: KeyValue<string, Capability[]>): string {
    return entry.key;
  }
Example #17
Source File: qualifier-chip-list.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
/**
   * Compares qualifier entries by their position in the object.
   */
  public qualifierKeyCompareFn = (a: KeyValue<string, any>, b: KeyValue<string, any>): number => {
    return this._qualifierKeys.indexOf(a.key) - this._qualifierKeys.indexOf(b.key);
  };