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

[All] make CoreShop stores more async, don't load them initially #1025

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ coreshop.address.resource = Class.create(coreshop.resource, {
value: true
});

pimcore.globalmanager.get('coreshop_countries').load();
pimcore.globalmanager.get('coreshop_address_identifier').load();
pimcore.globalmanager.get('coreshop_countries_active').load();
pimcore.globalmanager.get('coreshop_states').load();
pimcore.globalmanager.get('coreshop_zones').load();

coreshop.broker.fireEvent('resource.register', 'coreshop.address', this);
},

Expand Down Expand Up @@ -77,4 +71,4 @@ coreshop.address.resource = Class.create(coreshop.resource, {

coreshop.broker.addListener('pimcore.ready', function() {
new coreshop.address.resource();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ Ext.define('CoreShop.store.Country', {

name: 'country',
fieldLabel: t('coreshop_country'),

initComponent: function () {
this.store = pimcore.globalmanager.get('coreshop_countries');

this.callParent();
store: {
type: 'coreshop_countries'
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ Ext.define('CoreShop.store.State', {

name: 'state',
fieldLabel: t('coreshop_state'),

initComponent: function () {
this.store = pimcore.globalmanager.get('coreshop_states');

this.callParent();
store: {
type: 'coreshop_states'
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ Ext.define('CoreShop.store.Zone', {

name: 'zone',
fieldLabel: t('coreshop_zone'),

initComponent: function () {
this.store = pimcore.globalmanager.get('coreshop_zones');

this.callParent();
store: {
type: 'coreshop_zones'
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ coreshop.cart.pricerules.conditions.carriers = Class.create(coreshop.rules.condi

getForm: function () {
var me = this;
var store = pimcore.globalmanager.get('coreshop_carriers');

var carriers = {
fieldLabel: t('coreshop_carrier'),
typeAhead: true,
listWidth: 100,
width: 500,
store: store,
store: {
type: 'coreshop_carriers'
},
displayField: 'identifier',
valueField: 'id',
forceSelection: true,
Expand All @@ -32,15 +33,7 @@ coreshop.cart.pricerules.conditions.carriers = Class.create(coreshop.rules.condi
name: 'carriers',
maxHeight: 400,
delimiter: false,
listeners: {
beforerender: function () {
if (!store.isLoaded() && !store.isLoading())
store.load();

if (me.data && me.data.carriers)
this.setValue(me.data.carriers);
}
}
value: me.data.carriers
};

if (this.data && this.data.carriers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ pimcore.object.tags.coreShopStorePrice = Class.create(pimcore.object.tags.abstra

return false;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ coreshop.notification.rule.conditions.invoiceState = Class.create(coreshop.rules
name: 'invoiceState',
value: this.data ? this.data.invoiceState : [],
width: 250,
store: pimcore.globalmanager.get('coreshop_states_invoice'),
store: {
type: 'coreshop_states_invoice'
},
triggerAction: 'all',
typeAhead: false,
editable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ coreshop.notification.rule.conditions.carriers = Class.create(coreshop.rules.con

getForm: function () {
var me = this;
var store = pimcore.globalmanager.get('coreshop_carriers');

var carriers = {
fieldLabel: t('coreshop_carrier'),
typeAhead: true,
listWidth: 100,
width: 500,
store: store,
store: {
type: 'coreshop_carriers'
},
displayField: 'identifier',
valueField: 'id',
forceSelection: true,
Expand All @@ -33,15 +34,7 @@ coreshop.notification.rule.conditions.carriers = Class.create(coreshop.rules.con
name: 'carriers',
maxHeight: 400,
delimiter: false,
listeners: {
beforerender: function () {
if (!store.isLoaded() && !store.isLoading())
store.load();

if (me.data && me.data.carriers)
this.setValue(me.data.carriers);
}
}
value: me.data.carriers
};

if (this.data && this.data.carriers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ coreshop.notification.rule.conditions.paymentState = Class.create(coreshop.rules
name: 'paymentState',
value: this.data ? this.data.paymentState : [],
width: 250,
store: pimcore.globalmanager.get('coreshop_states_payment'),
store: {
type: 'coreshop_states_payment'
},
triggerAction: 'all',
typeAhead: false,
editable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ coreshop.notification.rule.conditions.shipmentState = Class.create(coreshop.rule
name: 'shipmentState',
value: this.data ? this.data.shipmentState : [],
width: 250,
store: pimcore.globalmanager.get('coreshop_states_shipment'),
store: {
type: 'coreshop_states_shipment'
},
triggerAction: 'all',
typeAhead: false,
editable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ coreshop.order.order.shipment = Class.create(coreshop.order.order.shipment, {
cb: null,

createWindow: function ($super, shipAbleItems) {
pimcore.globalmanager.get('coreshop_carriers').load();

var window = $super(shipAbleItems),
store = pimcore.globalmanager.get('coreshop_carriers'),
hasCarrier = this.order.shippingPayment.carrier !== null,
orderCarrierId = parseInt(this.order.carrier),
orderCarrierName = this.order.shippingPayment.carrier,
Expand All @@ -28,7 +25,9 @@ coreshop.order.order.shipment = Class.create(coreshop.order.order.shipment, {
xtype: 'combo',
fieldLabel: t('coreshop_carrier'),
mode: 'local',
store: store,
store: {
type: 'coreshop_carriers'
},
displayField: 'identifier',
valueField: 'id',
forceSelection: true,
Expand Down Expand Up @@ -60,25 +59,6 @@ coreshop.order.order.shipment = Class.create(coreshop.order.order.shipment, {
},
change: function() {
showToolTip = false;
},
afterrender: function () {
if (hasCarrier === true) {
var orderCarrierIndex;
if (store.isLoaded()) {
orderCarrierIndex = store.findExact('id', orderCarrierId);
if (orderCarrierIndex !== -1) {
this.setValue(store.getAt(orderCarrierIndex));
}
} else {
store.load();
store.on('load', function (store, records, options) {
orderCarrierIndex = store.findExact('id', orderCarrierId);
if (orderCarrierIndex !== -1) {
this.setValue(store.getAt(orderCarrierIndex));
}
}.bind(this));
}
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ coreshop.core.settings = Class.create({

this.data = Ext.decode(response.responseText).data;

this.getTabPanel();
this.loadStores();

}.bind(this)
});
},

loadStores: function()
{
this.stores = Ext.create('store.coreshop_stores').load(function() {
this.getTabPanel();
}.bind(this));
},

getValue: function (shopId, key) {
var current = null;

Expand Down Expand Up @@ -248,8 +255,7 @@ coreshop.core.settings = Class.create({

var me = this,
shopPanel,
store = pimcore.globalmanager.get('coreshop_stores'),
shop = store.getById(shopId);
shop = this.stores.getById(shopId);

if (!shop) {
alert('STORE NOT FOUND!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ coreshop.shippingrule.conditions.countries = Class.create(coreshop.rules.conditi

getForm: function () {
var me = this;
var store = pimcore.globalmanager.get('coreshop_countries');

var countries = {
fieldLabel: t('coreshop_condition_countries'),
typeAhead: true,
listWidth: 100,
width: 500,
store: store,
store: {
type: 'coreshop_countries'
},
displayField: 'name',
valueField: 'id',
forceSelection: true,
Expand All @@ -32,15 +33,7 @@ coreshop.shippingrule.conditions.countries = Class.create(coreshop.rules.conditi
name: 'countries',
height: 400,
delimiter: false,
listeners: {
beforerender: function () {
if (!store.isLoaded() && !store.isLoading())
store.load();

if (me.data && me.data.countries)
this.setValue(me.data.countries);
}
}
value: me.data.countries
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ coreshop.shippingrule.conditions.currencies = Class.create(coreshop.rules.condit

getForm: function () {
var me = this;
var store = pimcore.globalmanager.get('coreshop_currencies');

var currencies = {
fieldLabel: t('coreshop_condition_currencies'),
typeAhead: true,
listWidth: 100,
width: 500,
store: store,
store: {
type: 'coreshop_currencies'
},
displayField: 'name',
valueField: 'id',
forceSelection: true,
Expand All @@ -32,15 +33,7 @@ coreshop.shippingrule.conditions.currencies = Class.create(coreshop.rules.condit
name: 'currencies',
maxHeight: 400,
delimiter: false,
listeners: {
beforerender: function () {
if (!store.isLoaded() && !store.isLoading())
store.load();

if (me.data && me.data.currencies)
this.setValue(me.data.currencies);
}
}
value: me.data.currencies
};

if (this.data && this.data.currencies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ coreshop.shippingrule.conditions.zones = Class.create(coreshop.rules.conditions.

getForm: function () {
var me = this;
var store = pimcore.globalmanager.get('coreshop_zones');

var zones = {
fieldLabel: t('coreshop_condition_zones'),
typeAhead: true,
listWidth: 100,
width: 500,
store: store,
store: {
type: 'coreshop_zones'
},
displayField: 'name',
valueField: 'id',
forceSelection: true,
Expand All @@ -32,15 +33,7 @@ coreshop.shippingrule.conditions.zones = Class.create(coreshop.rules.conditions.
name: 'zones',
maxHeight: 400,
delimiter: false,
listeners: {
beforerender: function () {
if (!store.isLoaded() && !store.isLoading())
store.load();

if (me.data && me.data.zones)
this.setValue(me.data.zones);
}
}
value: me.data.zones
};

if (this.data && this.data.zones) {
Expand Down
Loading