PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / src / apps / js / admin / editor / actions / modal-course-items.js

modal-course-items.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at assets/src/apps/js/admin/editor/actions/modal-course-items.js

83 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const ModalCourseItems = {
2
3 toggle: function( context ) {
4 context.commit( 'TOGGLE' );
5 },
6
7 open: function( context, sectionId ) {
8 context.commit( 'SET_SECTION', sectionId );
9 context.commit( 'RESET' );
10 context.commit( 'TOGGLE' );
11 },
12
13 searchItems: function( context, payload ) {
14 context.commit( 'SEARCH_ITEMS_REQUEST' );
15
16 LP.Request( {
17 type: 'search-items',
18 query: payload.query,
19 item_type: payload.type,
20 page: payload.page,
21 exclude: JSON.stringify( [] ),
22 } ).then(
23 function( response ) {
24 var result = response.body;
25
26 if ( ! result.success ) {
27 return;
28 }
29
30 var data = result.data;
31
32 context.commit( 'SET_LIST_ITEMS', data.items );
33 context.commit( 'UPDATE_PAGINATION', data.pagination );
34 context.commit( 'SEARCH_ITEMS_SUCCESS' );
35 },
36 function( error ) {
37 context.commit( 'SEARCH_ITEMS_FAILURE' );
38
39 console.error( error );
40 }
41 );
42 },
43
44 addItem: function( context, item ) {
45 context.commit( 'ADD_ITEM', item );
46 },
47
48 removeItem: function( context, index ) {
49 context.commit( 'REMOVE_ADDED_ITEM', index );
50 },
51
52 addItemsToSection: function( context ) {
53 var items = context.getters.addedItems;
54
55 if ( items.length > 0 ) {
56 LP.Request( {
57 type: 'add-items-to-section',
58 section_id: context.getters.section,
59 items: JSON.stringify( items ),
60 } ).then(
61 function( response ) {
62 var result = response.body;
63
64 if ( result.success ) {
65 context.commit( 'TOGGLE' );
66
67 var items = result.data;
68 context.commit( 'ss/UPDATE_SECTION_ITEMS', {
69 section_id: context.getters.section,
70 items: items,
71 }, { root: true } );
72 }
73 },
74 function( error ) {
75 console.error( error );
76 }
77 );
78 }
79 },
80 };
81
82 export default ModalCourseItems;
83