<commit_before>define( [

  "dojo/_base/declare"
, "dojo/topic"
, "dojo/on"
, "dojo/when"

, "dijit/_WidgetBase"
, "dijit/_TemplatedMixin"
, "dijit/_WidgetsInTemplateMixin"
, "dijit/form/TextBox"
, "dijit/Destroyable"

, "hotplate/hotDojoSubmit/defaultSubmit"

, "hotplate/hotDojoWidgets/AlertBar"
, "hotplate/hotDojoWidgets/_OverlayMixin"

], function(

  declare
, topic
, on
, when

, _WidgetBase
, _TemplatedMixin
, _WidgetsInTemplateMixin
, TextBox
, Destroyable

, ds

, AlertBar
, _OverlayMixin

){

  return declare( [ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _OverlayMixin, Destroyable ] , {

    templateString: '<div><p>You need to set a template for this widget!</p></div>',

    // These will be defined by the templateString
    formWidget: null,
    alertBarWidget: null,
    buttonWidget: null,

    alertBarDomPlacement: 'first',

    storeName: '',
    store: null,

    //storeFields: {},
    recordId: null,

    // Default values for editing form
    defaultValues: {},

    resetOnSuccess: false,

    baseClass: 'editing-widget',

     // The store for records
    store: null,

    _firstResize: true,

    postCreate: function(){
      this.inherited(arguments);

      var self = this;

      // If there is no alertBarWidget defined, then make one up and
      // place it at the top of the form
      if( ! this.alertBarWidget ){
        this.alertBarWidget = new AlertBar();
        this.alertBarWidget.placeAt( this.formWidget.containerNode, this.alertBarDomPlacement );
      }
     
      // Artificially add a hidden id field to the form. This way, once the form has loaded,
      // the id will be stored and it will then be re-submitted 
      if( self.recordId ) {
        var idTextBox = new TextBox( { type:"hidden", name: self.store.idProperty, value: self.recordId } );
        idTextBox.placeAt( this.formWidget.containerNode, 'first' );
      }

      self.own(

        // When the form's overlay is clicked, try and show the form again
        on( self, 'overlayClick', function( e ){
          self.set( 'overlayStatus', { overlayed: false, clickable: false }  ); // CLICK OFF
          self.loadInfo();
        }),

        // Check self the record doesn't get updated by remote
        topic.subscribe('storeRecordUpdate', function( from, message, remote ){

          if( remote ){
            if( message.storeName === self.storeName && message.objectId == self.recordId ){
              self.set( 'overlayStatus', { overlayed: true, clickable: true }  ); // CLICK ON
            }
          }
        })
      );
<commit_msg>Added code so that clicking on a placeHolder will actually focus on the sibling widget<commit_after>define( [

  "dojo/_base/declare"
, "dojo/topic"
, "dojo/on"
, "dojo/when"
, "dojo/dom-class"

, "dijit/_WidgetBase"
, "dijit/_TemplatedMixin"
, "dijit/_WidgetsInTemplateMixin"
, "dijit/form/TextBox"
, "dijit/Destroyable"

, "hotplate/hotDojoSubmit/defaultSubmit"

, "hotplate/hotDojoWidgets/AlertBar"
, "hotplate/hotDojoWidgets/_OverlayMixin"

], function(

  declare
, topic
, on
, when
, domClass

, _WidgetBase
, _TemplatedMixin
, _WidgetsInTemplateMixin
, TextBox
, Destroyable

, ds

, AlertBar
, _OverlayMixin

){

  return declare( [ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _OverlayMixin, Destroyable ] , {

    templateString: '<div><p>You need to set a template for this widget!</p></div>',

    // These will be defined by the templateString
    formWidget: null,
    alertBarWidget: null,
    buttonWidget: null,

    alertBarDomPlacement: 'first',

    storeName: '',
    store: null,

    //storeFields: {},
    recordId: null,

    // Default values for editing form
    defaultValues: {},

    resetOnSuccess: false,

    baseClass: 'editing-widget',

     // The store for records
    store: null,

    _firstResize: true,

    postCreate: function(){
      this.inherited(arguments);

      var self = this;

      // If there is no alertBarWidget defined, then make one up and
      // place it at the top of the form
      if( ! this.alertBarWidget ){
        this.alertBarWidget = new AlertBar();
        this.alertBarWidget.placeAt( this.formWidget.containerNode, this.alertBarDomPlacement );
      }
     
      // Artificially add a hidden id field to the form. This way, once the form has loaded,
      // the id will be stored and it will then be re-submitted 
      if( self.recordId ) {
        var idTextBox = new TextBox( { type:"hidden", name: self.store.idProperty, value: self.recordId } );
        idTextBox.placeAt( this.formWidget.containerNode, 'first' );
      }

      self.own(

        // This is to make sure that DnD, if active, doesn't do a nasty preventDefault()
        // and therefore stops text selecting and moving cursor with mouse
        // Finding this one was a bit of a birch
        on( self.domNode, 'mousedown', function( e ){

          // For some reason, stopping propagation here will prevent focus
          // from happening if placeHolder there (!?). So, forcing focus on
          // previousSibling IF the click was on a placeholder;
          // TODO: UNDERSTAND WHY. This may have side effects. Stopping
          // propagation doesn't prevent the default from happening
          // if the placeHolder isn't there...
          if( domClass.contains( e.srcElement, 'dijitPlaceHolder' ) ){
            e.srcElement.previousSibling.focus();
          }
          
          // Stopping propagation, so that event won't reach the DnD
          // element above
          e.stopPropagation();
        }),

        // When the form's overlay is clicked, try and show the form again
        on( self, 'overlayClick', function( e ){
          self.set( 'overlayStatus', { overlayed: false, clickable: false }  ); // CLICK OFF
          self.loadInfo();
        }),

        // Check self the record doesn't get updated by remote
        topic.subscribe('storeRecordUpdate', function( from, message, remote ){

          if( remote ){
            if( message.storeName === self.storeName && message.objectId == self.recordId ){
              self.set( 'overlayStatus', { overlayed: true, clickable: true }  ); // CLICK ON
            }
          }
        })
      );

{'fraction_non_alphanumeric': 0.10970328789093825, 'fraction_numerical': 0.0, 'mean_word_length': 2.55125284738041, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1365224', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1848, 'n_words': 542}