Skip to content

Commit

Permalink
Merge pull request #16 from plentymarkets/scheduler
Browse files Browse the repository at this point in the history
set scheduler in checkout
  • Loading branch information
ggottwald authored Feb 13, 2017
2 parents 1cb7fd0 + 51738c2 commit 6a18b53
Show file tree
Hide file tree
Showing 10 changed files with 386 additions and 17 deletions.
12 changes: 0 additions & 12 deletions dist/plentymarketsCMStools-1.0.17.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/plentymarketsCMStools-1.0.17.min.js.map

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TemplateCache["waitscreen/waitscreen.html"] = "<div id=\"PlentyWaitScreen\" clas
(function( $ )
{
// will be overridden by grunt
var version = "1.0.17";
var version = "1.0.18";

/**
* Collection of uncompiled registered factories & services.
Expand Down Expand Up @@ -846,10 +846,15 @@ TemplateCache["waitscreen/waitscreen.html"] = "<div id=\"PlentyWaitScreen\" clas
pm.getRecentEvent().preventDefault();
//init
var basketItemsList = {};
var scheduler = {};
var $elem = $( elem );
var parentForm = $elem.parents( 'form' );
var $p_id = parentForm.find( '[name="P_ID"]:checked' );

scheduler.SchedulerInterval = parentForm.find( '[name="scheduler_interval"]' ).val();
scheduler.SchedulerRepeating = parentForm.find( '[name="scheduler_repeating"]' ).val();
scheduler.SchedulerDate = parentForm.find( '[name="scheduler_dateselector"]' ).val();

basketItemsList.BasketItemItemID = parentForm.find( '[name="ArticleID"]' ).val();
basketItemsList.BasketItemPriceID = parentForm.find( '[name="SYS_P_ID"]' ).val();
basketItemsList.BasketItemQuantity = parentForm.find( '[name^="ArticleQuantity"]' ).val();
Expand Down Expand Up @@ -883,6 +888,12 @@ TemplateCache["waitscreen/waitscreen.html"] = "<div id=\"PlentyWaitScreen\" clas
basketItemsList.BasketItemAttributesList = attributesList;
}

if(typeof scheduler.SchedulerInterval !== "undefined"
&& scheduler.SchedulerInterval > 0)
{
BasketService.setScheduler( scheduler );
}

//add basketItem and refresh previewLists
BasketService.addItem( [basketItemsList] );

Expand Down Expand Up @@ -3899,7 +3910,8 @@ PlentyFramework.cssClasses = {
editItemAttributes: editItemAttributes,
editOrderParams : editOrderParams,
addCoupon : addCoupon,
removeCoupon : removeCoupon
removeCoupon : removeCoupon,
setScheduler : setScheduler
};

/**
Expand Down Expand Up @@ -4538,6 +4550,22 @@ PlentyFramework.cssClasses = {
}
}

/**
* Set scheduler in checkout.
* @function setScheduler
* @param {Array} scheduler Array containing the scheduler data
* @return {object} <a href="http://api.jquery.com/category/deferred-object/" target="_blank">jQuery deferred
* Object</a>
*/
function setScheduler(scheduler)
{
return API.put("/rest/checkout/scheduler", scheduler)
.done( function()
{
updateContainer();
} );
}

}, ['APIFactory', 'UIFactory', 'CMSFactory', 'CheckoutFactory', 'ModalFactory'] );
}( jQuery, PlentyFramework ));

Expand Down
12 changes: 12 additions & 0 deletions dist/plentymarketsCMStools-1.0.18.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/plentymarketsCMStools-1.0.18.min.js.map

Large diffs are not rendered by default.

313 changes: 313 additions & 0 deletions dist/plentymarketsCMStools-libs-1.0.18.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plentymarketsCMStools",
"license": "AGPL-3.0",
"version": "1.0.17",
"version": "1.0.18",
"repository": "https://github.com/plentymarkets/plenty-cms-library.git",
"devDependencies": {
"grunt": "^0.4.5",
Expand Down
11 changes: 11 additions & 0 deletions src/directives/Basket.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
pm.getRecentEvent().preventDefault();
//init
var basketItemsList = {};
var scheduler = {};
var $elem = $( elem );
var parentForm = $elem.parents( 'form' );
var $p_id = parentForm.find( '[name="P_ID"]:checked' );

scheduler.SchedulerInterval = parentForm.find( '[name="scheduler_interval"]' ).val();
scheduler.SchedulerRepeating = parentForm.find( '[name="scheduler_repeating"]' ).val();
scheduler.SchedulerDate = parentForm.find( '[name="scheduler_dateselector"]' ).val();

basketItemsList.BasketItemItemID = parentForm.find( '[name="ArticleID"]' ).val();
basketItemsList.BasketItemPriceID = parentForm.find( '[name="SYS_P_ID"]' ).val();
basketItemsList.BasketItemQuantity = parentForm.find( '[name^="ArticleQuantity"]' ).val();
Expand Down Expand Up @@ -52,6 +57,12 @@
basketItemsList.BasketItemAttributesList = attributesList;
}

if(typeof scheduler.SchedulerInterval !== "undefined"
&& scheduler.SchedulerInterval > 0)
{
BasketService.setScheduler( scheduler );
}

//add basketItem and refresh previewLists
BasketService.addItem( [basketItemsList] );

Expand Down
19 changes: 18 additions & 1 deletion src/services/BasketService.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
editItemAttributes: editItemAttributes,
editOrderParams : editOrderParams,
addCoupon : addCoupon,
removeCoupon : removeCoupon
removeCoupon : removeCoupon,
setScheduler : setScheduler
};

/**
Expand Down Expand Up @@ -676,5 +677,21 @@
}
}

/**
* Set scheduler in checkout.
* @function setScheduler
* @param {Array} scheduler Array containing the scheduler data
* @return {object} <a href="http://api.jquery.com/category/deferred-object/" target="_blank">jQuery deferred
* Object</a>
*/
function setScheduler(scheduler)
{
return API.put("/rest/checkout/scheduler", scheduler)
.done( function()
{
updateContainer();
} );
}

}, ['APIFactory', 'UIFactory', 'CMSFactory', 'CheckoutFactory', 'ModalFactory'] );
}( jQuery, PlentyFramework ));

0 comments on commit 6a18b53

Please sign in to comment.