Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique assign data-source values. #145

Open
logicerpsolution opened this issue Mar 25, 2016 · 0 comments
Open

Unique assign data-source values. #145

logicerpsolution opened this issue Mar 25, 2016 · 0 comments

Comments

@logicerpsolution
Copy link

Hi Support,
I have some issue . I am creating control like set relationship between the entities. I have also attached the screenshot about control. In this control user select Foreign Entity after selection Foreign Attribute fill behalf of FE.

Problem : The problem is that user can select multiple FE and behalf of these FA will fill. But FA need unique behalf of FE. As you know we can only set single data-source. It contain last collection for all FA. Below is my code. Please give me solution to resolve this issue ASAP. I will very thankful to you do the same. I hope you will give best solution.

Meteor Template Code (TablesPopup)

{{#with JoinLoop}} {{#each this}}
                      <td>
                          <input class="form-control typeahead" name="team" type="text" id="Attribute{{this}}"
                                 placeholder="Attribute"
                                 autocomplete="off" spellcheck="off" data-select="selected"
                                 data-source="SelectedSalesForceTablesFields" 
                                 data-template="sftablesNametemplatePopUp" 
                                 data-value-key="name" />
                      </td>

                      <td>
                          <input class="form-control typeahead" id="ForeignEntity{{this}}" 
                                 name="team" 
                                 type="text"
                                 placeholder="*(Foreign Entity)"
                                 autocomplete="off" spellcheck="off" data-select="selected"
                                 data-source="SalesForceTables"
                                 data-key="ForeignEntity"
                                 data-relationalId="ForeignAttributeKey{{this}}"
                                 data-template="sftablesNametemplatePopUp"
                                 data-value-key="name" />
                      </td>

                      <td>
                          <input class="form-control typeahead" id="ForeignAttributeKey{{this}}" 
                          name="ForeignAttribute" type="text"
                          placeholder="Foreign Attribute" autocomplete="off" spellcheck="off" 
                          data-select="selected"
                          data-open="open"
                          data-source="SfTablesForeignAtt"
                          data-template="sftablesNametemplatePopUp" 
                          data-value-key="name" />
                      </td>

                      <td>
                          <div class="col-md-6">
                              <a href="javaScript:void(0)" id="MoreJoin" data-key="{{this}}"><i class="fa fa-plus fa-2x"></i></a>
                          </div>
                         {{#if IsMultipleJoinRow}} 
                          <div class="col-md-6">
                              <a href="javaScript:void(0)" id="DeleteJoin" data-key="{{this}}"><i class="fa fa-close fa-2x"></i></a>
                          </div>
                          {{/if}}
                      </td>

                  </tr>
                  {{/each}}
                  {{/with}}
              </tbody>

========================TablesPopup===========================

Template.SalesForceTablesPopup.helpers({

 Secondarysfobjects: function () {return Session.get("Secondarysfobjects");}

, Primarysfobjects: function () {return Session.get("Primarysfobjects");}
, GetSaleForceTablesName: function () {return Session.get("GetSaleForceTableName");}
, GetSaleForceTablesFields: function () {
return Session.get("GetSaleForceTableFields");
}
, SelectedSalesForceTablesFields: function () {return Session.get("GetSaleForceTableFields").fields;}
, JoinLoop: function () {
debugger;
var joinedRows = Template.instance().JoinLoop.get();
var lastRow = joinedRows[joinedRows.length - 1];
setTimeout(function () {
Meteor.typeahead.inject("#Attribute" + lastRow);
Meteor.typeahead.inject("#ForeignEntity" + lastRow);
Meteor.typeahead.inject("#ForeignAttributeKey" + lastRow);
}, 3000)
return joinedRows;
}
, IsMultipleJoinRow: function () {
return Template.instance().JoinLoop.get().length > 1;
}
, SalesForceTables: function () {
return Session.get("GetSaleForceTableName").map(function (key, index) {
return { "name": key.name, "tableId": key._id };
});
}
, SfTablesForeignAtt: function () {
var _CurrentOptions = Session.get("CurrentOptions");
var currentObjects = Session.get("SfTablesForeignAtt") || {};
if (typeof _CurrentOptions != "undefined") {
setTimeout(function () {
Meteor.typeahead.inject("#" + _CurrentOptions.ForeignAttributeId);
}, 3000);
return currentObjects[_CurrentOptions.TableName];
// return currentObjects;
} else {
return currentObjects;
}

}
, selected: function (event, suggestion, datasetName) {
if (event.target.dataset.key == "ForeignEntity") {
var array = Session.get("SfTablesForeignAtt") || {};
array.randomno = Random.id(10);
if (typeof array[suggestion.name] == "undefined") {
app.sf().GetSalesForceLocalTableFields(suggestion.tableId, function (data, status) {
if (status) {
array[suggestion.name] = data.fields.map(function (key, index) {
return { "name": key.name, "tableId": key._id };
});
Session.set("SfTablesForeignAtt", array);
Session.set("CurrentOptions", { "ForeignAttributeId": event.target.dataset.relationalid, "TableName": suggestion.name });
}
});
}
Session.set("SfTablesForeignAtt", array);
Session.set("CurrentOptions", { "ForeignAttributeId": event.target.dataset.relationalid, "TableName": suggestion.name });
}
}
})

Template.SalesForceTablesPopup.onRendered(function () {
// Meteor.typeahead.inject();
})

Template.SalesForceTablesPopup.onCreated(function () {
var _self = this;
var defaultValue = [];
defaultValue.push(1);
_self.JoinLoop = new ReactiveVar([]);
_self.CurrentOptions = new ReactiveVar();

_self.JoinLoop.set(defaultValue);

})

screenshot_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant