<commit_before>import Ember from 'ember';

const {on,computed,run} = Ember;
const computedProps = Ember.A(['minDate', 'maxDate', 'disabledDates', 'enabledDates', 'dateIcon', 'placeholder']);

var bsDateTimePickerComponent = Ember.Component.extend({
  concatenatedProperties: ['textFieldClassNames'],
  classNames: ['date'],
  classNameBindings: ['inputGroupClass'],
  textFieldClassNames: ['form-control'],
  bsDateTimePicker: null,
  dateIcon: 'glyphicon glyphicon-calendar',
  placeholder: '',

  inputGroupClass: computed('attrs.noIcon', function() {
    if (!this.getAttr('noIcon')) {
       return 'input-group';
     }
  }),

  _initDatepicker: on('didInsertElement', function() {
    var target;
    if (this.getAttr('noIcon')) {
      target = this.$('.' + this.get('textFieldClassNames').join('.'));
    } else {
      target = this.$();
    }
    var bsDateTimePicker = target.datetimepicker(this._buildConfig());
    var bsDateTimePickerFn = bsDateTimePicker.data('DateTimePicker');

    this.set('bsDateTimePicker', bsDateTimePickerFn);

    bsDateTimePicker.on('dp.change', ev => {
      run(() => {
        if(this.attrs.updateDate) {
          if (Ember.isNone(ev.date) || ev.date === false) {
            this.sendAction('updateDate', undefined);
          } else if (!ev.date.isSame(this.getAttr('date'))) {
            if (this.attrs.forceDateOutput) {
              this.sendAction('updateDate', ev.date.toDate());
            } else {
              this.sendAction('updateDate', ev.date);
            }
          }
        }
        else {
          //warn
        }
      });
    });

    this._updateDateTimePicker();

    if (this.attrs.open) {
      this.get('bsDateTimePicker').show();
    }
  }),

  didReceiveAttrs() {
    this._updateDateTimePicker();
  },

  _updateDateTimePicker() {

    var dateTimePicker = this.get('bsDateTimePicker');
    if(dateTimePicker) {
      if (this.getAttr('disabled')) {
        dateTimePicker.disable();
      } else {
        dateTimePicker.enable();
      }

      if (this.getAttr('date') === undefined) {
        dateTimePicker.date(null);
      } else {
        dateTimePicker.date(this.getAttr('date'));
      }

      if (!this.getAttr('minDate')) {<commit_msg>Setup change event after render<commit_after>import Ember from 'ember';

const {on,computed,run} = Ember;
const computedProps = Ember.A(['minDate', 'maxDate', 'disabledDates', 'enabledDates', 'dateIcon', 'placeholder']);

var bsDateTimePickerComponent = Ember.Component.extend({
  concatenatedProperties: ['textFieldClassNames'],
  classNames: ['date'],
  classNameBindings: ['inputGroupClass'],
  textFieldClassNames: ['form-control'],
  bsDateTimePicker: null,
  dateIcon: 'glyphicon glyphicon-calendar',
  placeholder: '',

  inputGroupClass: computed('attrs.noIcon', function() {
    if (!this.getAttr('noIcon')) {
       return 'input-group';
     }
  }),

  _initDatepicker: on('didInsertElement', function() {
    var target;
    if (this.getAttr('noIcon')) {
      target = this.$('.' + this.get('textFieldClassNames').join('.'));
    } else {
      target = this.$();
    }
    var bsDateTimePicker = target.datetimepicker(this._buildConfig());
    var bsDateTimePickerFn = bsDateTimePicker.data('DateTimePicker');

    this.set('bsDateTimePicker', bsDateTimePickerFn);

    run.scheduleOnce('afterRender', this, this._setupChangeEvent, bsDateTimePicker);

    this._updateDateTimePicker();

    if (this.attrs.open) {
      this.get('bsDateTimePicker').show();
    }
  }),

  didReceiveAttrs() {
    this._updateDateTimePicker();
  },
  
  _setupChangeEvent(bsDateTimePicker) {
    bsDateTimePicker.on('dp.change', ev => {
      run(() => {
        if(this.attrs.updateDate) {
          if (Ember.isNone(ev.date) || ev.date === false) {
            this.sendAction('updateDate', undefined);
          } else if (!ev.date.isSame(this.getAttr('date'))) {
            if (this.attrs.forceDateOutput) {
              this.sendAction('updateDate', ev.date.toDate());
            } else {
              this.sendAction('updateDate', ev.date);
            }
          }
        }
        else {
          //warn
        }
      });
    });
  },

  _updateDateTimePicker() {

    var dateTimePicker = this.get('bsDateTimePicker');
    if(dateTimePicker) {
      if (this.getAttr('disabled')) {
        dateTimePicker.disable();
      } else {
        dateTimePicker.enable();
      }

      if (this.getAttr('date') === undefined) {
        dateTimePicker.date(null);
      } else {
        dateTimePicker.date(this.getAttr('date'));
      }

      if (!this.getAttr('minDate')) {
{'fraction_non_alphanumeric': 0.16106655105137654, 'fraction_numerical': 0.0, 'mean_word_length': 2.86756077116513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4902459', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1365, 'n_words': 221}