Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.    SETUPonInit: function (component, helper) {
  4.         var presentationId = component.get("v.presentationId");
  5.         helper.REFACTOREDcreateSequenceRowComponents(component, helper, presentationId);
  6.         // Load existing sequences only on update
  7.         if(presentationId){
  8.             this.runAction(
  9.                 component,
  10.                 "c.getSequencesToUpdate",
  11.                 {
  12.                     'presentationId': presentationId
  13.                 },
  14.                 function (sequencesToUpdate) {
  15.                     this.REFACTOREDautoMatch(component, helper, JSON.parse(sequencesToUpdate));
  16.                 }
  17.             );
  18.         }
  19.     },
  20.  
  21.     /**
  22.      * Dynamically creates components for displaying Sequence rows in a table
  23.      * @param presentationId null for insert context.
  24.      */
  25.     SETUPcreateSequenceRowComponents : function(component, helper, presentationId) {
  26.         var sequencesData = component.get("v.sequencesData");
  27.         var isUpdate = Boolean(presentationId);
  28.         var presentationType = component.get("v.presentationType");
  29.         //TODO
  30.         var defaultOption= {
  31.             label: presentationType == "ZIP" ? $A.get('$Label.c.CLMBulkUploaderStep2NewSequence') :
  32.                    presentationType == "PDF" ? $A.get('$Label.c.CLMBulkUploaderStep2NewPage') : "",
  33.             value: ""
  34.         };
  35.         var sequenceRowsDescriptions = [];
  36.         sequencesData.forEach(function(sequenceData, i){
  37.             sequenceRowsDescriptions.push(
  38.                 [
  39.                     "c:CLMBulkSequencesRow",
  40.                     {
  41.                         "aura:id": sequenceData.key + '_' + i,
  42.                         "sequenceData": sequenceData,
  43.                         "index": i+1,
  44.                         "isUpdate": isUpdate,
  45.                         "autoMatchOptions": {!v.autoMatchOptions},//TODO
  46.                         "oldAutoMatchOption":  defaultOption
  47.                     }
  48.                 ]
  49.             );
  50.         });
  51.         this.createComps(
  52.             sequenceRowsDescriptions,
  53.             function (newComponents) {
  54.                 component.set("v.sequenceRowComponents", newComponents);
  55.                 helper.hideSpinner(component);
  56.             }
  57.         );
  58.     },
  59.  
  60.  
  61.     /**
  62.      * Automatically updates CLMBulkSequencesRow with a Sequence To Update each time their names match.
  63.      * @param sequencesToUpdate JSON array of sequences that may be used to update CLMBulkSequencesRow's.
  64.      */
  65.     SETUPautoMatch : function(component, helper, sequencesToUpdate) {
  66.         var sequenceRowComponents = component.get("v.sequenceRowComponents");
  67.         sequenceRowComponents.forEach(function(sequenceRowComponent){
  68.             let sequenceData = sequenceRowComponent.get("v.sequenceData");
  69.             let name = sequenceData.name;
  70.             for(let i = 0, length =  sequencesToUpdate.length; i < length; ++i){
  71.                 if(name == sequencesToUpdate[i].sequence.Name){
  72.                     let sequenceToUpdate = sequencesToUpdate[i].sequence;
  73.                     sequenceData.IsMandatory = sequenceToUpdate.IsMandatory__c;
  74.                     //TODO set other row values and selected option
  75.                     sequenceRowComponent.set("v.sequenceData", sequenceData);
  76.                     sequencesToUpdate.splice(i, 1);
  77.                     break;
  78.                 }
  79.             }
  80.         });
  81.         var autoMatchOptions = [];
  82.         sequencesToUpdate.forEach(function(sequenceToUpdate){
  83.             autoMatchOptions.push(
  84.                 {
  85.                     label:sequenceToUpdate.sequence.Name,
  86.                     value:sequenceToUpdate.sequence.Id
  87.                 }
  88.             );
  89.         });
  90.         component.set("v.autoMatchOptions", autoMatchOptions);
  91.     },
  92.  
  93.     /**
  94.      * Handles change on Sequence To Update column (auto match)
  95.      * fires event with selected and previously selected values
  96.      */
  97.     ROWonSequenceToUpdateChange: function (component, event) {
  98.         var autoMatchOptions = component.get("v.autoMatchOptions");
  99.         //TODO add oldAutoMatchOption to autoMatchOptions and remove selectedAutoMatchOption from autoMatchOptions
  100.     },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement