Ejemplo n.º 1
0
    test('with modifications', function() {

      var newStart = new Date(2011, 7, 1);
      var startDate = InputParser.exportDate(newStart);
      var startTime = InputParser.exportTime(newStart);

      var newEnd = new Date(2012, 7, 1);
      var endDate = InputParser.exportDate(newEnd);
      var endTime = InputParser.exportTime(newEnd);

      var expected = {
        startDate: newStart,
        endDate: newEnd,
        title: 'foo',
        description: 'bar',
        location: 'zomg',
        calendarId: this.calendar._id
      };

      setFieldValue('startDate', startDate);
      setFieldValue('startTime', startTime);
      setFieldValue('endDate', endDate);
      setFieldValue('endTime', endTime);

      setFieldValue('title', expected.title);
      setFieldValue('description', expected.description);
      setFieldValue('location', expected.location);

      assert.hasProperties(subject.formData(), expected);
    });
Ejemplo n.º 2
0
  _updateUI: function() {
    this._overrideEvent();
    this.form.reset();

    var model = this.event;
    this.getEl('title').value = model.title;
    this.getEl('location').value = model.location;
    var dateSrc = model;
    if (model.remote.isRecurring && this.busytime) {
      dateSrc = this.busytime;
    }

    var startDate = dateSrc.startDate;
    var endDate = dateSrc.endDate;
    this._duration = endDate.getTime() - startDate.getTime();

    // update the allday status of the view
    var allday = this.getEl('allday');
    if (allday && (allday.checked = model.isAllDay)) {
      this._toggleAllDay();
      endDate = this.formatEndDate(endDate);
    }

    this.getEl('startDate').value = InputParser.exportDate(startDate);
    this._setupDateTimeSync(
      'date', 'startDate', 'start-date-locale', startDate);

    this.getEl('endDate').value = InputParser.exportDate(endDate);
    this._setupDateTimeSync(
      'date', 'endDate', 'end-date-locale', endDate);

    this.getEl('startTime').value = InputParser.exportTime(startDate);
    this._setupDateTimeSync(
      'time', 'startTime', 'start-time-locale', startDate);

    this.getEl('endTime').value = InputParser.exportTime(endDate);
    this._setupDateTimeSync(
      'time', 'endTime', 'end-time-locale', endDate);

    this.getEl('description').textContent = model.description;

    // update calendar id
    this.getEl('calendarId').value = model.calendarId;

    // calendar display
    var currentCalendar = this.getEl('currentCalendar');

    if (this.originalCalendar) {
      currentCalendar.value =
        this.originalCalendar.remote.name;

      currentCalendar.readOnly = true;
    }

    this.updateAlarms(model.isAllDay);
  },
Ejemplo n.º 3
0
    function updatesValues(overrides, callback) {
      // just to verify we actually clear fields...
      getEl('title').value = 'foo';
      event.remote.description = '<span>foo</span>';

      var expected = {
        title: remote.title,
        location: remote.location,
        startDate: InputParser.exportDate(remote.startDate),
        startTime: InputParser.exportTime(remote.startDate),
        endDate: InputParser.exportDate(remote.endDate),
        endTime: InputParser.exportTime(remote.endDate),
        currentCalendar: calendar.remote.name
      };

      if (overrides) {
        for (var key in overrides) {
          expected[key] = overrides[key];
        }
      }

      function verify() {
        /*jshint validthis:true */
        if (subject.provider.canCreateEvent) {
          expected.calendarId = this.event.calendarId;
        }

        for (var key in expected) {
          if (expected.hasOwnProperty(key)) {
            assert.equal(
              fieldValue(key),
              expected[key],
              'should set "' + key + '"'
            );
          }
        }

        var curCal = getEl('currentCalendar');
        assert.isTrue(curCal.readOnly, 'current calendar readonly');

        expected = escapeHTML(event.remote.description);

        assert.equal(
          getEl('description').innerHTML,
          expected
        );

        callback();
      }

      subject.onfirstseen();
      subject.onafteronfirstseen = function() {
        subject.useModel(busytime, event, verify);
      };
    }
Ejemplo n.º 4
0
 _setEndDateTimeWithCurrentDuration: function() {
   var date = new Date(this._getStartDateTime() + this._duration);
   var endDateLocale = this._findElement('endDateLocale');
   var endTimeLocale = this._findElement('endTimeLocale');
   this.getEl('endDate').value = InputParser.exportDate(date);
   this.getEl('endTime').value = InputParser.exportTime(date);
   this._renderDateTimeLocale(endDateLocale, date);
   this._renderDateTimeLocale(endTimeLocale, date);
 },
Ejemplo n.º 5
0
 _resetDateTime: function() {
   // if start event was "all day" and switch to regular event start/end time
   // will be the same, so we reset to default start time, otherwise we keep
   // the previously selected value
   var startDateTime = this._getStartDateTime();
   if (startDateTime === this._getEndDateTime()) {
     var startDate = new Date(startDateTime);
     this._setDefaultHour(startDate);
     this.getEl('startTime').value = InputParser.exportTime(startDate);
     this._renderDateTimeLocale(
       this._findElement('startTimeLocale'), startDate);
     // default event duration is 1 hour
     this._duration = 60 * 60 * 1000;
     this._setEndDateTimeWithCurrentDuration();
   }
 },