根据选择输入长时间启用/禁用按钮

时间:2017-12-18 15:55:17

标签: javascript meteor

我需要创建一个系统,根据用户在"导演"中选择的时间,从用户列表中启用和禁用特定用户的app中的按钮。角色。

导演可以选择为基本用户启用模板的每一天:

<template name="showSend">
        <h4>Send Notification to: {{data.profile.lastName}} {{data.profile.firstName}}</h4>
        <form>
          <select name="notification">
            <option value="1day">1 day</option>
            <option value="3day">3 days</option>
            <option value="5day">5 days</option>
            <option value="week">1 week</option>
          </select>
          <br><br>
          <label><input type="submit" name={{data.profile.lastName}} id="sendQuest" ><span><i class="fa fa-bell" aria-hidden="true"></i> Send</span></label>
        </form> 
    </template>

另一方面,用户看到按钮:

<template name="dashboard">
...
<button type="submit" class="btn btn-primary" id="yes">Yes</button>
...
</template>

我的用户集合是:

    Schemas.UserProfile = new SimpleSchema(

  firstName:
    type: String
    optional: true

  lastName:
    type: String
    optional: true

  personNumber:
    type: String
    optional: true


  birthday:
    type: Date
    optional: true


  location:
    type: String
    optional: true

  country:
    type: String
    label: 'Nationality'
    allowedValues: Utils.countryList
    optional: true

  clinic:
    type: String
    label: 'Clinic'
    allowedValues: Utils.clinicList
    optional: true
)

Schemas.User = new SimpleSchema(

  username:
    type: String
    regEx: /^[a-z0-9A-Z_]{3,15}$/
    optional: true


  emails:
    type: [Object]
    optional: true

  "emails.$.address":
    type: String
    regEx: SimpleSchema.RegEx.Email

  "emails.$.verified":
    type: Boolean

  createdAt:
    type: Date

  profile:
    type: Schemas.UserProfile
    optional: true

  services:
    type: Object
    optional: true
    blackbox: true

  roles:
    type: [String]
    blackbox: true
    optional: true
)

1 个答案:

答案 0 :(得分:0)

注意:

  1. 你还没有试图展示你到目前为止所尝试的内容。
  2. 您的解释并不十分明确,需要一段时间才能了解您确切需要的内容。
  3. 基于以上所述,我无法分享任何特定代码,但会尝试指出正确的方向,以便让您开始使用此代码。

    到目前为止,我的理解是:

    1. 导演可以为每个用户设置时间范围。
    2. 用户将能够看到&#34;是&#34;在该时间范围内提交按钮。
    3. 您的方法可能如下所示:

      1. 当导演设置时间范围并提交时,您可以在Schemas.UserProfile中使用到期日期时间戳创建一个新字段(您可以通过添加到期时间来计算此字段)当前时间到达将来禁用按钮的时间)或者,您可以将此数据保存在新的集合中(可能包含用户ID与到期时间)
      2. 在仪表板模板的帮助程序中,您可以比较当前时间与到期时间。如果您在到期时间内,请显示按钮。如果没有,您可以选择禁用该按钮。 (或者你想做的任何事情,因为你还没有完全提到那部分)