Changeset 1996509
- Timestamp:
- 12/17/2018 02:50:19 PM (7 years ago)
- Location:
- amilia-store/trunk
- Files:
-
- 4 edited
-
amilia-store.php (modified) (3 diffs)
-
shortcodes/amilia-store-standings-client.js (modified) (2 diffs)
-
shortcodes/amilia-store-standings.js (modified) (7 diffs)
-
shortcodes/amilia-store-standings.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amilia-store/trunk/amilia-store.php
r1995135 r1996509 6 6 Author: Martin Drapeau <martin.drapeau@amilia.com> 7 7 Copyright: 2014-2018 Amilia 8 Version: 2.9. 28 Version: 2.9.3 9 9 Author URI: http://www.amilia.com/ 10 10 License: Apache License 2.0 … … 51 51 "error-no-tags" => __("Oh no! You haven't set up tags yet. Checkout <a href='https://support.amilia.com/hc/en-us/articles/216528783-How-to-create-your-first-tag-' target='_blank'>this how to article</a>", 'amilia-store'), 52 52 "error-no-programs" => __("No programs found.", 'amilia-store'), 53 "error-no-sub-categories" => __("No sub-categories found.", 'amilia-store'), 53 54 "help" => __("Help", 'amilia-store'), 54 55 "instructions" => __("Instructions", 'amilia-store'), … … 105 106 "game-schedule" => __("Game schedule", 'amilia-store'), 106 107 "standings-instructions-p1" => __("This is an experimental feature and works in conjunction with score and attendance tracking (https://lab.amilia.com/attendance).", 'amilia-store'), 107 "standings-instructions-p2" => __("Choose the program in which you have activities representing teams (1 activity = 1 team).", 'amilia-store'),108 "standings-instructions-p2" => __("Choose the program and sub-category in which you have activities representing teams and the league (1 activity = 1 team, 1 sub-category = 1 league).", 'amilia-store'), 108 109 "standings-instructions-p3" => __("You can optionally filter activities shown by tags allowing you to exclude activities which are not teams.", 'amilia-store'), 109 110 "standings-instructions-p4" => __("The sport you choose determines how to count and display score and standings.", 'amilia-store'), 110 111 "select-program" => __("Select a program", 'amilia-store'), 112 "select-sub-category" => __("Select a sub-category (optional)", 'amilia-store'), 111 113 "show-hidden-activities" => __("Show hidden activities", 'amilia-store'), 112 114 "show-staff" => __("Show staff", 'amilia-store'), -
amilia-store/trunk/shortcodes/amilia-store-standings-client.js
r1995041 r1996509 14 14 var events = []; 15 15 var programId = options.program; 16 var subCategoryId = options.subCategory; 16 17 var showHidden = options.showHidden; 17 18 var showStaff = options.showStaff; … … 85 86 for (var i = 0; i < events.length; i++) { 86 87 var event = events[i]; 88 if (subCategoryId && event.SubCategoryId != subCategoryId) continue; 87 89 if (tagIds.length) { 88 90 var found = false; -
amilia-store/trunk/shortcodes/amilia-store-standings.js
r1995041 r1996509 22 22 ' <select name="program"></select>', 23 23 ' <div class="input-helper program"></div>', 24 '</div>', 25 '<div class="form-group">', 26 ' <label>{select-sub-category} <a class="amilia-help" href="#">(?)</a></label>', 27 ' <select name="sub-category"></select>', 28 ' <div class="input-helper sub-category"></div>', 24 29 '</div>', 25 30 '<div class="form-group">', … … 84 89 programSelect = modal.querySelector('select[name="program"]'), 85 90 programSelectError = modal.querySelector('div.input-helper.program'), 91 subCategorySelect = modal.querySelector('select[name="sub-category"]'), 92 subCategorySelectError = modal.querySelector('div.input-helper.sub-category'), 86 93 tagsSelect = modal.querySelector('select[name="tags[]"]'), 87 94 tagsSelectError = modal.querySelector('div.input-helper.tags'), … … 118 125 119 126 programSelect.innerHTML = ''; 120 programSelectError.innerHTML = ='';127 programSelectError.innerHTML = ''; 121 128 122 129 if (orgPrograms.length > 0) { … … 134 141 }, 135 142 function(xhr) { 136 programSelectError.innerHTML == Amilia.lang('error-unexpected'); 143 programSelectError.innerHTML = Amilia.lang('error-unexpected'); 144 } 145 ); 146 } 147 148 function getSelectedSubCategory() { 149 var subCategoryId = parseInt(subCategorySelect.value, 10); 150 return isNaN(subCategoryId) ? null : subCategoryId; 151 } 152 153 function fetchSubCategoriesAndConstructSelect(selectedProgram, selectedSubCategory) { 154 selectedProgram || (selectedProgram = getSelectedProgram()); 155 if (!selectedProgram) return; 156 157 selectedSubCategory || (selectedSubCategory = getSelectedSubCategory()); 158 subCategorySelectError.innerHTML = ''; 159 160 var urlComponents = Amilia.getUrlComponents(storeUrl.value); 161 if (urlComponents == null) return; 162 163 subCategorySelectError.innerHTML = Amilia.lang('pleaseWait'); 164 Amilia.ajaxGetJson(urlComponents.apiUrl + 'Programs/' + selectedProgram + '/Activities?showHidden=true', 165 function(xhr) { 166 var response = JSON.parse(xhr.response) || {}; 167 var activities = response.Items; 168 169 subCategorySelect.innerHTML = '<option value=""></option>'; 170 subCategorySelectError.innerHTML = ''; 171 172 if (activities.length > 0) { 173 var usedIds = []; 174 for (var i = 0; i < activities.length; i++) { 175 var activity = activities[i]; 176 if (usedIds.indexOf(activity.SubCategoryId) >= 0) continue; 177 var option = document.createElement('option'); 178 option.value = activity.SubCategoryId; 179 option.innerText = activity.CategoryName + ' > ' + activity.SubCategoryName; 180 if (selectedSubCategory == activity.SubCategoryId) option.selected = true; 181 subCategorySelect.appendChild(option); 182 usedIds.push(activity.SubCategoryId); 183 } 184 } else { 185 subCategorySelectError.innerHTML = Amilia.lang('error-no-sub-categories'); 186 } 187 }, 188 function(xhr) { 189 subCategorySelectError.innerHTML = Amilia.lang('error-unexpected'); 137 190 } 138 191 ); … … 182 235 } 183 236 184 function validateStoreUrlAndFetchProgramAndTags(selectedProgram, selected Tags) {237 function validateStoreUrlAndFetchProgramAndTags(selectedProgram, selectedSubCategory, selectedTags) { 185 238 Amilia.validateStoreUrl(storeUrl, storeUrlError, 186 239 function() { 187 240 fetchProgramsAndConstructSelect(selectedProgram); 188 241 fetchTagsAndConstructSelect(selectedTags); 242 fetchSubCategoriesAndConstructSelect(selectedProgram, selectedSubCategory); 189 243 }); 190 244 } … … 194 248 }; 195 249 250 programSelect.onchange = function() { 251 fetchSubCategoriesAndConstructSelect(selectedSubCategory); 252 } 253 196 254 function generateShortCode() { 197 255 var urlComponents = Amilia.getUrlComponents(storeUrl.value); 198 256 var program = getSelectedProgram(); 257 var subCategory = getSelectedSubCategory(); 199 258 var tags = getSelectedTags(); 200 return '[' + SHORTCODE + " url='{url}' sport='{sport}' program='{program}' tags='{tags}' showhidden='{show-hidden}' showstaff='{show-staff}' show='{show}' api='{api}']"259 return '[' + SHORTCODE + " url='{url}' sport='{sport}' program='{program}' subcategory='{sub-category}' tags='{tags}' showhidden='{show-hidden}' showstaff='{show-staff}' show='{show}' api='{api}']" 201 260 .replace('{url}', storeUrl.value) 202 261 .replace('{sport}', sportSelect.value) 203 262 .replace('{program}', program) 263 .replace('{sub-category}', subCategory || '') 204 264 .replace('{tags}', tags.join(',')) 205 265 .replace('{show-hidden}', showHidden.checked ? 1 : 0) … … 253 313 254 314 var program = activeShortcode.shortcode.attrs.named.program; 315 var subCategory = activeShortcode.shortcode.attrs.named.subcategory; 255 316 var tags = (activeShortcode.shortcode.attrs.named.tags + '').split(','); 256 317 for (var i = 0; i < tags.length; i++) tags[i] = parseInt(tags[i], 10); 257 validateStoreUrlAndFetchProgramAndTags(program, tags);318 validateStoreUrlAndFetchProgramAndTags(program, subCategory, tags); 258 319 259 320 showSelect.value = activeShortcode.shortcode.attrs.named.show || 'standings,schedule'; -
amilia-store/trunk/shortcodes/amilia-store-standings.php
r1995041 r1996509 5 5 'sport' => 'soccer', 6 6 'program' => '', 7 'subcategory' => '', 7 8 'tags' => '', 8 9 'showhidden' => false, … … 18 19 $program = $a['program']; 19 20 if (!is_numeric($program)) $program = 'null'; 21 $subCategory = $a['subcategory']; 22 if (!is_numeric($subCategory)) $subCategory = 'null'; 20 23 $tags = $a['tags']; 21 24 $showHidden = $a['showhidden'] == 1 ? 1 : 0; … … 75 78 tags: [$tags], 76 79 program: $program, 80 subCategory: $subCategory, 77 81 showHidden: $showHidden, 78 82 showStaff: $showStaff,
Note: See TracChangeset
for help on using the changeset viewer.