<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(['dojo/_base/declare',
        'dojo/on',
        'dijit/_WidgetBase',
        'dijit/_TemplatedMixin',
        'dojo/text!./templates/StudyAreaItem.html',
        'dojo/i18n!app/nls/resources',
        'dojo/topic',
        'app/base/context/app-topics',
        'app/base/studyarea/studyarea-util',
        'app/ui/util/ConfirmationDialog'
      ],
function(declare, on,
         _WidgetBase, _TemplatedMixin, template,
         i18n, topic, appTopics, studyAreaUtil,
         ConfirmationDialog) {

  var oThisClass = declare([_WidgetBase, _TemplatedMixin], {

    i18n: i18n,
    templateString: template,

    constructor: function(studyarea) {
      this.studyarea = studyarea;
    },

    postCreate: function() {
      this.inherited(arguments);
      this._initUI();
      this._initEvents();
    },

    _initEvents: function() {
      var self = this;
      this.own(
        on(this.listItemActionsNode, 'click', function(evt) {
          var target = evt.srcElement || evt.target;
          var actionType = target.getAttribute('data-studyarea-action');
          //console.log(actionType);
          if(actionType === 'activate') {
            self.activateStudyArea();
          } else if (actionType === 'delete') {
            self.deleteStudyArea();
          }
        }),
        on(this.deactiveButton, 'click', function() {
          self.deactivateStudyArea();
        })
      );
    },

    _initUI: function() {
      this.studyAreaNameNode.textContent = this.studyarea.name;
    },

    activateStudyArea: function() {
      this.domNode.classList.add('active');
      this.onActivate();
      AppContext.activeProject.activeStudyArea = this.studyarea;
      topic.publish(appTopics.StudyAreaActivated,this.studyarea);
    },

    deactivateStudyArea: function() {
      this.domNode.classList.remove('active');
      this.onDeactivate();
      AppContext.activeProject.activeStudyArea = null;
      topic.publish(appTopics.StudyAreaDeactivated,this.studyarea);
    },

    deleteStudyArea: function () {
      var self = this,
          d = new ConfirmationDialog({
            status: 'danger',
            title: i18n.studyArea.deletion.deleteCaption,
            prompt: i18n.studyArea.deletion.deleteConfirmation,
            okLabel: i18n.studyArea.deletion.deleteButton
          });
      d.confirm().then(function(confirmed) {
        if(confirmed) self.onRemove();
      });
    },

    onActivate: function() {},

    onDeactivate: function() {},

    onRemove: function() {}

  });

  return oThisClass;
});
</pre></body></html>