Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SETUPonInit: function (component, helper) {
- var presentationId = component.get("v.presentationId");
- helper.REFACTOREDcreateSequenceRowComponents(component, helper, presentationId);
- // Load existing sequences only on update
- if(presentationId){
- this.runAction(
- component,
- "c.getSequencesToUpdate",
- {
- 'presentationId': presentationId
- },
- function (sequencesToUpdate) {
- this.REFACTOREDautoMatch(component, helper, JSON.parse(sequencesToUpdate));
- }
- );
- }
- },
- /**
- * Dynamically creates components for displaying Sequence rows in a table
- * @param presentationId null for insert context.
- */
- SETUPcreateSequenceRowComponents : function(component, helper, presentationId) {
- var sequencesData = component.get("v.sequencesData");
- var isUpdate = Boolean(presentationId);
- var presentationType = component.get("v.presentationType");
- //TODO
- var defaultOption= {
- label: presentationType == "ZIP" ? $A.get('$Label.c.CLMBulkUploaderStep2NewSequence') :
- presentationType == "PDF" ? $A.get('$Label.c.CLMBulkUploaderStep2NewPage') : "",
- value: ""
- };
- var sequenceRowsDescriptions = [];
- sequencesData.forEach(function(sequenceData, i){
- sequenceRowsDescriptions.push(
- [
- "c:CLMBulkSequencesRow",
- {
- "aura:id": sequenceData.key + '_' + i,
- "sequenceData": sequenceData,
- "index": i+1,
- "isUpdate": isUpdate,
- "autoMatchOptions": {!v.autoMatchOptions},//TODO
- "oldAutoMatchOption": defaultOption
- }
- ]
- );
- });
- this.createComps(
- sequenceRowsDescriptions,
- function (newComponents) {
- component.set("v.sequenceRowComponents", newComponents);
- helper.hideSpinner(component);
- }
- );
- },
- /**
- * Automatically updates CLMBulkSequencesRow with a Sequence To Update each time their names match.
- * @param sequencesToUpdate JSON array of sequences that may be used to update CLMBulkSequencesRow's.
- */
- SETUPautoMatch : function(component, helper, sequencesToUpdate) {
- var sequenceRowComponents = component.get("v.sequenceRowComponents");
- sequenceRowComponents.forEach(function(sequenceRowComponent){
- let sequenceData = sequenceRowComponent.get("v.sequenceData");
- let name = sequenceData.name;
- for(let i = 0, length = sequencesToUpdate.length; i < length; ++i){
- if(name == sequencesToUpdate[i].sequence.Name){
- let sequenceToUpdate = sequencesToUpdate[i].sequence;
- sequenceData.IsMandatory = sequenceToUpdate.IsMandatory__c;
- //TODO set other row values and selected option
- sequenceRowComponent.set("v.sequenceData", sequenceData);
- sequencesToUpdate.splice(i, 1);
- break;
- }
- }
- });
- var autoMatchOptions = [];
- sequencesToUpdate.forEach(function(sequenceToUpdate){
- autoMatchOptions.push(
- {
- label:sequenceToUpdate.sequence.Name,
- value:sequenceToUpdate.sequence.Id
- }
- );
- });
- component.set("v.autoMatchOptions", autoMatchOptions);
- },
- /**
- * Handles change on Sequence To Update column (auto match)
- * fires event with selected and previously selected values
- */
- ROWonSequenceToUpdateChange: function (component, event) {
- var autoMatchOptions = component.get("v.autoMatchOptions");
- //TODO add oldAutoMatchOption to autoMatchOptions and remove selectedAutoMatchOption from autoMatchOptions
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement