/* * Licensed Materials - Property of IBM * * IBM Cognos Products: SHARE * * (C) Copyright IBM Corp. 2015, 2017 * * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define([ 'bi/schedule/views/CadencePickerView', 'bi/schedule/app/appControler', 'jquery', 'bi/sharecommon/utils/translator', 'q', 'bi/sharecommon/utils/simpledoT', 'text!bi/schedule/templates/TriggerCadencePicker.html', 'underscore' ], function (View, controler, $, t, Q, dot, template, _) { 'use strict'; var triggerCadence = View.extend({ /** * @constructor */ init: function(options) { triggerCadence.inherited('init', this, arguments); this.isEditMode = false; this.scheduleInfo = {}; _.extend(this, options); if(typeof(this.objectInformation.descriptor)!=="undefined"){ this.scheduleInfo = this.objectInformation.descriptor.scheduleInfo; this.isEditMode = true; } this.uniqueId = _.uniqueId(); }, /** * Render the new schedule view month picker section * */ render: function() { var deferred = Q.defer(); var htmlGenerator = dot.simpleTemplate(template); var triggerName = " "; if (this.isEditMode && this.scheduleInfo.trigger) { triggerName = this.scheduleInfo.trigger.triggerName; } var attributes = { schedule_trigger_name_label: t.translate("schedule_trigger_name_label"), schedule_trigger_name_value: triggerName, uniqueId: this.uniqueId }; this.$el.append(htmlGenerator(attributes)); deferred.resolve(this); return deferred.promise; }, /** All views should overwrite this function. * It takes a partially populated json schedule descriptor and adds to it * based on the properties of this view. * @param desc the partial JSON schedule descriptor * @returns the descriptor passed in, with added attributes. */ toDescriptor: function(desc) { desc.trigger = { triggerName: _.escape(this.$el.find('.schedule_trigger_name_input').val().trim()) }; desc.everyNPeriods = 1; // mandatory, even though it makes little sense for triggers return desc; }, validate: function(msgs) { if(this.$el.find('.schedule_trigger_name_input').val().trim() === "") { msgs.push(t.translate("schedule_invalid_trigger_name_empty")); } return msgs; } }); return triggerCadence; });