1app.controller('showRegistrationController', ['$scope', '$rootScope', '$q', '$state', '$stateParams', '$timeout', 'localStorageService', 'lists', 'showsService', 'permissionsService', 'webApiSettings', 'adminCompanySettingsService', '$location', 'lists', 2 function ($scope, $rootScope, $q, $state, $stateParams, $timeout, localStorageService, lists, showsService, permissionsService, webApiSettings, adminCompanySettingsService, $location, lists) { 3 4 $scope.initializePage = function () { 5 6 $scope.getShow(); 7 $scope.getCategories(); 8 }; 9 10 $scope.getShow = function () { 11 12 showsService.getShowByIdAndOwnerUserId($scope.showId).then(function (results) { 13 14 if (results.data.shows.length > 0) { 15 // Set the show information 16 $scope.show = results.data.shows[0]; 17 18 $scope.canRegisterForShow = $scope.show.allowOnlineRegistration; 19 $scope.show.selectedFieldsForEditing = JSON.parse($scope.show.selectedFieldsForEditing); 20 21 $scope.pageIsLoaded = true; 22 23 } else { 24 // Show that no show was returned 25 popMessage("error", "Not Found", "The show cannot be found."); 26 } 27 28 29 30 }, function (error) { 31 popApiErrorMessage(error); 32 }); 33 34 } 35 36 $scope.getCategories = function () { 37 showsService.GetAllShowCategories($scope.showId).then(function (results) { 38 39 if (results.data.categories.length > 0) { 40 // Set the categories 41 $scope.categories = results.data.categories; 42 $scope.prepareShowItems(); 43 } else { 44 // Show that no categories are found 45 popMessage("error", "Not Found", "No categories found."); 46 } 47 48 $scope.pageIsLoaded = true; 49 50 }, function (error) { 51 popApiErrorMessage(error); 52 }); 53 }; 54 55 //PZ - Modifications for only allowing categories that are tagged 56 $scope.isCategoryDisabled = function (categoryItem) { 57 //By default, we'll assume a category is disabled. 58 //This takes care of the situation with deactivated categories. 59 var result = true; 60 try { 61 $.each($scope.show.showCategoryTags, function (categoryTagIndex, categoryTagItem) { 62 if (categoryTagItem.categoryId == categoryItem.categoryId) { 63 //We found the category tag for this category item. 64 //If it is not selected then it's disabled 65 result = !categoryTagItem.isSelected; 66 return false; //break 67 } 68 }); 69 } 70 catch (e) { 71 result = true; 72 } 73 return result; 74 }; 75 76 $scope.prepareShowItems = function () { 77 //We need to make sure the parent has retrieved the show before we can proceed 78 //We can tell by comparing the showId from the $stateParams against the one from the parent. 79 //Once the parent has hydrated the show, the IDs will match. 80 if ($scope.show.showId != $scope.showId) { 81 $timeout($scope.prepareShowItems, 500); 82 } else { 83 $.each($scope.show.showItems, function (showItemIndex, showItem) { 84 $scope.prepareShowItemForDisplay(showItem, $scope.show.secondsUntilEnd); 85 }); 86 } 87 }; 88 89 $scope.prepareShowItemForDisplay = function (showItem, showSecondsUntilEnd) { 90 91 //The JSON object comes back from the database as a string. Convert it to a JSON Object. 92 if (showItem.categoryFieldsValues != null && showItem.categoryFieldsValues.length > 0) { 93 showItem.categoryFieldsValues = angular.fromJson(showItem.categoryFieldsValues); 94 } else { 95 showItem.categoryFieldsValues = []; 96 } 97 98 99 if (showSecondsUntilEnd < 0 || $scope.show.secondsUntilOnlineRegistrationCloses < 0) { 100 101 // Since registration is closed, check to see if there are any selected fields that can be editted 102 if ($scope.show.secondsUntilEditingOnSelectFieldsCloses > 0 && $scope.show.selectedFieldsForEditing.length > 0) { 103 $scope.someFieldsEditable = true; 104 } 105 try { 106 showItem.canEdit = $scope.isInRole('Super Admin'); 107 } catch (e) { 108 showItem.canEdit = false; 109 } 110 } else { 111 showItem.canEdit = true; 112 } 113 114 // Set the show category fields 115 $scope.insertShowItemCategoryFields(showItem); 116 }; 117 118 $scope.onShowItemCategoryChange = function (showItem, fieldId) { 119 // Clear out what was returned from the database since we don't want to just add new 120 // caegtory fields to the existing category fields from the previous category 121 showItem.categoryFieldsValues = []; 122 // Insert the new category fields for the new category 123 $scope.insertShowItemCategoryFields(showItem); 124 // Save the show item with the new category
125 $scope.saveShowItem(showItem, fieldId); 126 }; 127 128 $scope.insertShowItemCategoryFields = function (showItem) { 129 showItem.categoryFields = []; 130 131 $.each($scope.categories, function (categoryItemIndex, category) { 132 if (category.active) { 133 if (showItem.categoryId == category.categoryId) { 134 $.each(category.categoryFields, function (categoryFieldIndex, categoryField) { 135 if (categoryField.active) { 136 137 categoryField.canEdit = showItem.canEdit; 138 if ($scope.someFieldsEditable) { 139 $.each($scope.show.selectedFieldsForEditing, function (index, selectedField) { 140 if (selectedField.categoryFieldId == categoryField.categoryFieldId) { 141 categoryField.canEdit = true; 142 return false; 143 } 144 }); 145 } 146 147 // Create an object so if a value is not returned from the database it is defaulted to nothing. 148 var fieldValue = { 149 selectedText: '', 150 selectedCategoryFieldOption: '', 151 selectedCategoryFieldOptionText: '', 152 selectedLinkText: '', 153 selectedLinkUrl: '' 154 }; 155 156 // Match the current category field with a category 157 // field returned from the database in showItem.categoryFieldValues 158 // to populate the saved values 159 $.each(showItem.categoryFieldsValues, function (valueIndex, valueItem) { 160 if (valueItem.id == categoryField.categoryFieldId) { 161 fieldValue = angular.copy(valueItem); 162 return false; 163 } 164 }); 165 166 switch (categoryField.categoryFieldTypeId) { 167 case 1: 168 categoryField.selectedText = fieldValue.selectedText; 169 break; 170 case 2: 171 categoryField.selectedCategoryFieldOption = fieldValue.selectedCategoryFieldOption; 172 categoryField.selectedCategoryFieldOptionText = fieldValue.selectedCategoryFieldOptionText 173 break; 174 case 3: 175 categoryField.selectedLinkText = fieldValue.selectedLinkText; 176 categoryField.selectedLinkUrl = fieldValue.selectedLinkUrl; 177 break; 178 case 4: 179 categoryField.gridContent = fieldValue.gridContent; 180 break; 181 } 182 showItem.categoryFields.push(angular.copy(categoryField)); 183 } 184 }); 185 } 186 } 187 }); 188 }; 189 190 $scope.toggleExpanded = function (showItem) { 191 if ($scope.expandedShowItemId != showItem.showItemId) { 192 $scope.expandedShowItemId = showItem.showItemId; 193 194 $timeout(function () { 195 $scope.bindDynamicDropZone(showItem, "/api/v1/files/UploadImageJpeg", ".jpg, .jpeg, .png, .gif"); 196 }, 0); 197 } else { 198 $scope.expandedShowItemId = 0; 199 } 200 }; 201
202 $scope.saveCategoryField = function (showItem, categoryField, fieldId) { 203 showItem = $scope.updateShowItemCategoryFieldValues(showItem, categoryField); 204 205 //Try to calculate the weight per day if the user entered a value for a field named "weight" or "birth date" or "birth weight" 206 var categoryFieldNameToCheck = categoryField.name.toLowerCase().trim().replace(/\s+/g, '_'); //replace all spaces, not just the first one 207 208 if ($scope.weightFieldNames.indexOf(categoryFieldNameToCheck) > -1 || $scope.birthDateFieldNames.indexOf(categoryFieldNameToCheck) > -1 || $scope.birthWeightFieldNames.indexOf(categoryFieldNameToCheck) > -1) { 209 try { 210 //find the current weight 211 var current_weight = 0; 212 $.each(showItem.categoryFields, function (index, categoryField) { 213 var categoryFieldNameToCheck = categoryField.name.toLowerCase().replace(/\s+/g, '_'); //replace all spaces, not just the first one 214 if ($scope.weightFieldNames.indexOf(categoryFieldNameToCheck) > -1) { 215 //found the category field for birth date 216 current_weight = categoryField.selectedText; 217 return false; 218 } 219 }); 220 221 //first get the birth date 222 var birth_date = ""; 223 $.each(showItem.categoryFields, function (index, categoryField) { 224 var categoryFieldNameToCheck = categoryField.name.toLowerCase().replace(/\s+/g, '_'); //replace all spaces, not just the first one 225 if ($scope.birthDateFieldNames.indexOf(categoryFieldNameToCheck) > -1) { 226 //found the category field for birth date 227 birth_date = categoryField.selectedText; 228 return false; 229 } 230 }); 231 232 if (birth_date && birth_date != null && birth_date != 'undefined') { 233 //do the calculation 234 var numberOfDaysSinceBirth = moment().diff(moment(birth_date), 'days'); 235 236 //find the weight of the animal the day it was born 237 var birth_weight = 0; 238 $.each(showItem.categoryFields, function (index, categoryField) { 239 var categoryFieldNameToCheck = categoryField.name.toLowerCase().replace(/\s+/g, '_'); //replace all spaces, not just the first one 240 if ($scope.birthWeightFieldNames.indexOf(categoryFieldNameToCheck) > -1) { 241 //found the category field for birth date 242 if (categoryField.selectedText.length > 0 && !isNaN(categoryField.selectedText)) { 243 // If it is a number, set the birth weight otherwise leave it at 0 244 birth_weight = categoryField.selectedText; 245 } 246 return false; 247 } 248 }); 249 250 //now figure out the weight per day 251 var weight_per_day = (parseFloat(current_weight) - parseFloat(birth_weight)) / numberOfDaysSinceBirth; 252 253 if (!isNaN(weight_per_day)) { 254 weight_per_day = weight_per_day.toFixed(2); 255 256 //see if there's a "weight per day" field and set it's selected text 257 $.each(showItem.categoryFields, function (index, categoryField) { 258 var categoryFieldNameToCheck = categoryField.name.toLowerCase().replace(/\s+/g, '_'); //replace all spaces, not just the first one 259 if ($scope.weightPerDayFieldNames.indexOf(categoryFieldNameToCheck) > -1) { 260 //found the category field for birth date 261 categoryField.selectedText = weight_per_day.toString() + ' as of ' + moment().format("MM/DD/YYYY"); 262 $scope.updateShowItemCategoryFieldValues(showItem, categoryField); 263 return false; 264 } 265 }); 266 } 267 } 268 } catch (e) { 269 //Do nothing 270 } 271 } 272
273 $scope.saveShowItem(showItem, fieldId); 274 }; 275 276 $scope.saveShowItem = function (showItem, fieldId) { 277 278 showsService.upsertShowItemByOwner(showItem).then(function (results) { 279 280 if (fieldId != null) { 281 $('#' + fieldId).addClass("has-success"); 282 $timeout(function () { $('#' + fieldId).removeClass("has-success"); }, 5000); 283 } else { 284 //No field was given to highlight, so we'll toast instead 285 popMessage('success', 'Show Item Saved', 'Show item information saved successfully'); 286 } 287 288 }, function (error) { 289 if (fieldId != null) { 290 $('#' + fieldId).addClass("has-error"); 291 } 292 popApiErrorMessage(error); 293 }); 294 }; 295 296 $scope.isDigitalSwineRegistrationField = function (categoryFieldName) { 297 categoryFieldName = categoryFieldName.toLowerCase(); 298 categoryFieldName = categoryFieldName.replace('_', ' '); 299 300 if ( 301 categoryFieldName == "registration" || categoryFieldName == "registration number" || categoryFieldName == "registration id" || 302 categoryFieldName == "digital swine registration" || categoryFieldName == "digital swine registration number" || categoryFieldName == "digital swine registration id" 303 ) { 304 return true; 305 } else { 306 return false; 307 } 308 } 309 310 $scope.lookupDigitalSwineRegistrationNumber = function (showItem, registrationNumber) { 311 var deferred = $q.defer(); 312 313 var itemBreed = "not-set"; 314 315 $.each(showItem.categoryFields, function (index, categoryField) { 316 317 if (categoryField.name === "Breed") { 318 //itemBreed = categoryField.selectedCategoryFieldOptionText; 319 320 if (categoryField.selectedCategoryFieldOption) { 321 //Loop through and get the selection (pain in the ass!!!) 322 $.each(categoryField.categoryFieldOptions, function (index, categoryFieldOption) { 323 if (categoryFieldOption.categoryFieldOptionId.toString() === categoryField.selectedCategoryFieldOption) { 324 itemBreed = categoryFieldOption.value; 325 } 326 }); 327 } 328 329 } 330 }); 331 332 if (isNaN(registrationNumber)) { 333 popMessage("warning", "Invalid Registration Number", 'Invalid Registration Number Entered.'); 334 deferred.resolve(); 335 } else { 336 337 showsService.digitalSwineGetAnimal(registrationNumber, itemBreed).then(function (results) { 338 339 var animals = results.data.animals; 340 341 if (animals.length == 0) { 342 popMessage("warning", "No Animal Found", 'No animal was found with that registration number.'); 343 } 344 else { 345 var isAnyFieldFilled = false; 346 var isAnyFieldSkipped = false; 347 348 var theDataToUse = ""; 349 350 351 352 //ownerName 353 theDataToUse = animals[0]["owner_name"]; 354 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 355 if (showItem.ownerName && showItem.ownerName.trim().length > 0) { 356 //We need to let the user know that we're ignoring this field because it was already filled 357 isAnyFieldSkipped = true; 358 } else { 359 isAnyFieldFilled = true; 360 showItem.ownerName = theDataToUse; 361 } 362 } 363 364 //showPersonName 365 theDataToUse = animals[0]["owner_name"]; 366 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 367 if (showItem.showPersonName && showItem.showPersonName.trim().length > 0) { 368 //We need to let the user know that we're ignoring this field because it was already filled 369 isAnyFieldSkipped = true; 370 } else { 371 isAnyFieldFilled = true; 372 showItem.showPersonName = theDataToUse; 373 } 374 } 375 376 //ownerAddress1 377 theDataToUse = animals[0]["address_line_1"]; 378 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 379 if (showItem.ownerAddress1 && showItem.ownerAddress1.trim().length > 0) { 380 //We need to let the user know that we're ignoring this field because it was already filled 381 isAnyFieldSkipped = true; 382 } else { 383 isAnyFieldFilled = true; 384 showItem.ownerAddress1 = theDataToUse; 385 } 386 } 387 388 //ownerAddress2 389 theDataToUse = animals[0]["address_line_2"]; 390 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 391 if (showItem.ownerAddress2 && showItem.ownerAddress2.trim().length > 0) { 392 //We need to let the user know that we're ignoring this field because it was already filled 393 isAnyFieldSkipped = true; 394 } else { 395 isAnyFieldFilled = true; 396 showItem.ownerAddress2 = theDataToUse; 397 } 398 } 399 400 //ownerCity 401 theDataToUse = animals[0]["city"]; 402 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 403 if (showItem.ownerCity && showItem.ownerCity.trim().length > 0) { 404 //We need to let the user know that we're ignoring this field because it was already filled 405 isAnyFieldSkipped = true; 406 } else { 407 isAnyFieldFilled = true; 408 showItem.ownerCity = theDataToUse; 409 } 410 } 411 412 //ownerState 413 theDataToUse = animals[0]["state"]; 414 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 415 if (showItem.ownerState && showItem.ownerState.trim().length > 0) { 416 //We need to let the user know that we're ignoring this field because it was already filled 417 isAnyFieldSkipped = true; 418 } else { 419 isAnyFieldFilled = true; 420 showItem.ownerState = theDataToUse; 421 } 422 } 423 424 //ownerPostalCode 425 theDataToUse = animals[0]["zip_code"]; 426 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 427 if (showItem.ownerPostalCode && showItem.ownerPostalCode.trim().length > 0) { 428 //We need to let the user know that we're ignoring this field because it was already filled 429 isAnyFieldSkipped = true; 430 } else { 431 isAnyFieldFilled = true; 432 showItem.ownerPostalCode = theDataToUse; 433 } 434 } 435 436 //showItemName 437 theDataToUse = animals[0]["animal_name"]; 438 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 439 if (showItem.name && showItem.name.trim().length > 0) { 440 //We need to let the user know that we're ignoring this field because it was already filled 441 isAnyFieldSkipped = true; 442 } else { 443 isAnyFieldFilled = true; 444 showItem.name = theDataToUse; 445 } 446 } 447 448 //officialName 449 theDataToUse = animals[0]["animal_name"]; 450 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 451 if (showItem.officialName && showItem.officialName.trim().length > 0) { 452 //We need to let the user know that we're ignoring this field because it was already filled 453 isAnyFieldSkipped = true; 454 } else { 455 isAnyFieldFilled = true; 456 showItem.officialName = theDataToUse; 457 } 458 } 459 460 //animal_sex 461 theDataToUse = animals[0]["animal_sex"]; 462 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 463 if (showItem.animalSex && showItem.animalSex.trim().length > 0) { 464 //We need to let the user know that we're ignoring this field because it was already filled 465 isAnyFieldSkipped = true; 466 } else { 467 isAnyFieldFilled = true;
468 showItem.animalSex = theDataToUse; 469 } 470 } 471 472 //ear notch 473 theDataToUse = animals[0]["ear_notch"]; 474 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 475 if (showItem.earNotch && showItem.earNotch.trim().length > 0) { 476 //We need to let the user know that we're ignoring this field because it was already filled 477 isAnyFieldSkipped = true; 478 } else { 479 isAnyFieldFilled = true; 480 showItem.earNotch = theDataToUse; 481 } 482 } 483 484 //breeder 485 theDataToUse = animals[0]["breeder_name"]; 486 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 487 if (showItem.breederName && showItem.breederName.trim().length > 0) { 488 //We need to let the user know that we're ignoring this field because it was already filled 489 isAnyFieldSkipped = true; 490 } else { 491 isAnyFieldFilled = true; 492 showItem.breederName = theDataToUse; 493 } 494 } 495 496 //breeder state 497 theDataToUse = animals[0]["breeder_state"]; 498 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 499 if (showItem.breederState && showItem.breederState.trim().length > 0) { 500 //We need to let the user know that we're ignoring this field because it was already filled 501 isAnyFieldSkipped = true; 502 } else { 503 isAnyFieldFilled = true; 504 showItem.breederState = theDataToUse; 505 } 506 } 507 508 //sire of dam 509 theDataToUse = animals[0]["sire_of_dam"]; 510 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse != '') { 511 if (showItem.sireOfDam && showItem.sireOfDam.trim().length > 0) { 512 //We need to let the user know that we're ignoring this field because it was already filled 513 isAnyFieldSkipped = true; 514 } else { 515 isAnyFieldFilled = true; 516 showItem.sireOfDam = theDataToUse; 517 } 518 } 519 520 521 $.each(showItem.categoryFields, function (index, categoryField) { 522 523 if (categoryField.categoryFieldTypeId == 1) { 524 //Only Textboxes 525 var categoryFieldNameToCheck = categoryField.name.toLowerCase().replace(/\s+/g, '_'); //replace all spaces, not just the first one 526 527 //field name traslations to data kets go here~~~~~~~~~ 528 if (categoryFieldNameToCheck == "litter_mates" || categoryFieldNameToCheck == "litter_of") { 529 categoryFieldNameToCheck = "littermates"; 530 } 531 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 532 533 //Translations 534 if (categoryFieldNameToCheck == "dob") categoryFieldNameToCheck = "birth_date"; 535 if (categoryFieldNameToCheck == "birth_day") categoryFieldNameToCheck = "birth_date"; 536 if (categoryFieldNameToCheck == "date_of_birth") categoryFieldNameToCheck = "birth_date"; 537 if (categoryFieldNameToCheck == "far_date") categoryFieldNameToCheck = "birth_date"; 538 if (categoryFieldNameToCheck == "farrowing_date") categoryFieldNameToCheck = "birth_date"; 539 540 if (categoryFieldNameToCheck == "weight_at_birth") categoryFieldNameToCheck = "birth_
540weight"; 541 if (categoryFieldNameToCheck == "bwt") categoryFieldNameToCheck = "birth_weight"; 542 if (categoryFieldNameToCheck == "wab") categoryFieldNameToCheck = "birth_weight"; 543 544 if (categoryFieldNameToCheck == "sire") categoryFieldNameToCheck = "sire_animal_name"; 545 if (categoryFieldNameToCheck == "dam") categoryFieldNameToCheck = "dam_animal_name"; 546 547 var theDataToUse = animals[0][categoryFieldNameToCheck]; 548 549 if (theDataToUse != null && theDataToUse != 'undefined' && theDataToUse.toString() != '') { 550 if (categoryField.selectedText && categoryField.selectedText.toString().trim().length > 0) { 551 //We need to let the user know that we're ignoring this field because it was already filled 552 isAnyFieldSkipped = true; 553 } else { 554 isAnyFieldFilled = true; 555 556 if (categoryFieldNameToCheck == "littermates") { 557 //This is an array. We want to know how many littermates there are in this field. 558 categoryField.selectedText = theDataToUse.length; 559 } else { 560 categoryField.selectedText = theDataToUse; 561 } 562 563 564 $scope.updateShowItemCategoryFieldValues(showItem, categoryField); 565 } 566 } 567 } 568 569 }); 570 571 if (isAnyFieldFilled) { 572 if (isAnyFieldSkipped) { 573 popMessage("info", "Some Fields Skipped", 'Animal information was found and filled in, but some fields already had values defined. These fields have not been overwritten.'); 574 } else { 575 popMessage("success", "Fields Populated", 'Animal information was found and filled in.'); 576 } 577 $scope.saveShowItem(showItem, ''); 578 } else { 579 popMessage("warning", "No Fields Filled", 'Animal information was found, but no information was filled out. This is either because all information is already filled in, or because no category field names match the data.'); 580 } 581 } 582 583 deferred.resolve(); 584 585 }, function (error) { 586 popApiErrorMessage(error); 587 deferred.resolve(); 588 }); 589 590 } 591 return deferred.promise; 592 593 594 } 595 596 $scope.updateShowItemCategoryFieldValues = function (showItem, categoryField) { 597 598 var fieldObject = {}; 599 var markForDeletion = false; 600 601 switch (categoryField.categoryFieldTypeId) { 602 case 1: 603 fieldObject.id = categoryField.categoryFieldId; 604 fieldObject.name = categoryField.name; 605 fieldObject.selectedText = categoryField.selectedText; 606 607 // Check if the new value is empty and if so mark it for removal 608 markForDeletion = fieldObject.selectedText.length < 1; 609 610 break; 611 case 2: 612 fieldObject.id = categoryField.categoryFieldId; 613 fieldObject.name = categoryField.name; 614 fieldObject.selectedCategoryFieldOption = categoryField.selectedCategoryFieldOption; 615 616 var selectedFieldOptionText = ''; 617 $.each(categoryField.categoryFieldOptions, function (optionIndex, optionItem) { 618 if (optionItem.categoryFieldOptionId == categoryField.selectedCategoryFieldOption) { 619 selectedFieldOptionText = optionItem.value; 620 return false; 621 } 622 }); 623
624 fieldObject.selectedCategoryFieldOptionText = selectedFieldOptionText; 625 626 // Check if the new value is empty and if so mark it for removal 627 markForDeletion = fieldObject.selectedCategoryFieldOptionText.length < 1; 628 629 break; 630 case 3: 631 fieldObject.id = categoryField.categoryFieldId; 632 fieldObject.name = categoryField.name; 633 fieldObject.selectedLinkText = categoryField.selectedLinkText; 634 fieldObject.selectedLinkUrl = categoryField.selectedLinkUrl; 635 636 // Check if the new value is empty and if so mark it for removal 637 markForDeletion = fieldObject.selectedLinkText.length < 1 && fieldObject.selectedLinkUrl.length < 1; 638 639 break; 640 case 4: 641 fieldObject.id = categoryField.categoryFieldId; 642 fieldObject.name = categoryField.name; 643 fieldObject.gridContent = categoryField.gridContent; 644 645 // Check if the new value is empty and if so mark it for removal 646 markForDeletion = fieldObject.gridContent.rows.length < 1; 647 648 break; 649 } 650 651 //Find the object in the categoryFieldsValues of the showItem 652 //Replace it if it exists, push it if it doesn't 653 if (!angular.isArray(showItem.categoryFieldsValues)) { 654 showItem.categoryFieldsValues = []; 655 } 656 var foundIndex = -1; 657 $.each(showItem.categoryFieldsValues, function (index, categoryFieldValue) { 658 if (categoryFieldValue.id == fieldObject.id) { 659 foundIndex = index; 660 return false; 661 } 662 }); 663 664 if (foundIndex == -1) { 665 //this value has not been previously saved, so push it onto the array 666 showItem.categoryFieldsValues.push(fieldObject); 667 } else { 668 669 if (markForDeletion) { 670 showItem.categoryFieldsValues.splice(foundIndex, 1); 671 } else { 672 //this value is being updated, so replace it 673 showItem.categoryFieldsValues[foundIndex] = fieldObject; 674 } 675 } 676 677 return showItem; 678 679 }; 680 681 682 683 $scope.bindDynamicDropZone = function (showItem, apiUrl, allowedFiles) { 684 685 var serviceBase = webApiSettings.serviceBaseUri; 686 var divSelector = 'div#' + 'fileUpload_' + showItem.showItemId; 687 688 var dropZoneDiv = $(divSelector).html(); 689 if (dropZoneDiv == null || dropZoneDiv.length > 0) { 690 //There either is no div displaying (probably because of paging) or the div that is displaying already has 691 //a dropzone bound to it 692 return; 693 } 694 695 try { 696 Dropzone.autoDiscover = false; 697 var fileUploadDropzone = new Dropzone( 698 divSelector, 699 { 700 url: serviceBase + apiUrl, 701 acceptedFiles: allowedFiles, 702 dictDefaultMessage: "Click or drop files here to upload.", 703 headers: { "Authorization": 'bearer ' + $scope.user.access_token } 704 }); 705 fileUploadDropzone.on("addedfile", function (file) { 706 //if (this.files[1] != null) { 707 // this.removeFile(this.files[0]); 708 //} 709 }); 710 fileUploadDropzone.on("complete", function (data) { 711 if (data.status == 'error') { 712 if (data && data.xhr && data.xhr.response && data.xhr.response.length > 0) { 713 popMessage("error", "Error", data.xhr.response); 714 } else { 715 popMessage("error", "Error", "Failed to upload file. Please ensure you are uploading an allowed file type. Acceptable File Types are jpg, png, and gif."); 716 } 717 } else { 718 $scope.$apply(function () { 719 720 var imageUrl = data.xhr.response; 721 722 //Save the image to the showItemImages 723 $scope.upsertShowItemImage(showItem, imageUrl, false); 724 725 }); 726 727 var myDropzone = Dropzone.forElement(divSelector); 728 myDropzone.removeFile(data); 729 } 730 731 }); 732 733 } catch (error) { 734 if (error.description != 'Dropzone already attached.') { 735 popMessage("error", "Error", error.message); 736 } 737 } 738 }; 739 740 $scope.toggleFullScreenImage = function (selectedImage) { 741 if (selectedImage != null) { 742 if (selectedImage.isVideo) { 743 selectedImage.videoSrc = $sce.trustAsHtml(selectedImage.imageUrl) 744 $scope.fullScreenImage = selectedImage; 745 } else { 746 //TODO: replace sm with lg 747 selectedImage.lgImage = selectedImage.imageUrl.replace(/_sm_/i, '_lg_'); 748 $scope.fullScreenImage = selectedImage; 749 } 750 } else { 751 $scope.fullScreenImage = null; 752 } 753 $scope.showFullScreenImage = !$scope.showFullScreenImage; 754 }; 755 756 $scope.upsertShowItemVideo = function (showItem) { 757 showsService.upsertShowItemImageByOwner(showItem.showId, -1, showItem.showItemId, showItem.newVideoEmbed, true, true).then(function (results) { 758 759 showItem.showItemImages.push( 760 { 761 showItemImageId: results.data.results[0].c
761ode, 762 showItemId: showItem.showItemId, 763 imageUrl: showItem.newVideoEmbed, 764 sequence: showItem.showItemImages.length, 765 active: true, 766 isVideo: true 767 } 768 ); 769 770 showItem.newVideoEmbed = ""; 771 772 }, function (error) { 773 popApiErrorMessage(error); 774 }); 775 }; 776 777 $scope.upsertShowItemImage = function (showItem, imageUrl, isVideo) { 778 779 showsService.upsertShowItemImageByOwner(showItem.showId, -1, showItem.showItemId, imageUrl, true, isVideo).then(function (results) { 780 781 showItem.showItemImages.push( 782 { 783 showItemImageId: results.data.results[0].code, 784 showItemId: showItem.showItemId, 785 imageUrl: imageUrl, 786 sequence: showItem.showItemImages.length, 787 active: true, 788 isVideo: false 789 } 790 ); 791 792 }, function (error) { 793 popApiErrorMessage(error); 794 }); 795 796 }; 797 798 $scope.deactivateShowItemImage = function (showItem, showItemImage, index) { 799 var deferred = $q.defer(); 800 801 showsService.upsertShowItemImageByOwner(showItem.showId, showItemImage.showItemImageId, showItem.showItemId, showItemImage.imageUrl, false, showItemImage.isVideo).then(function (results) { 802 showItem.showItemImages.splice(index, 1); 803 deferred.resolve(); 804 }, function (error) { 805 popApiErrorMessage(error); 806 deferred.resolve(); 807 }); 808 809 return deferred.promise; 810 }; 811 812 $scope.addNewShowItem = function (scrollToBottom) { 813 814 var deferred = $q.defer(); 815 816 var showItem = {}; 817 818 showItem.showId = $scope.show.showId; 819 showItem.showItemId = -1; 820 821 //PZ - Modifications for only allowing categories that are tagged. Pick a default category 822 var categoryId = -1; 823 if ($scope.categories.length > 0) { 824 $.each($scope.categories, function (categoryIndex, categoryItem) { 825 if ($scope.isCategoryDisabled(categoryItem)) { 826 return true; //continue 827 } else { 828 categoryId = categoryItem.categoryId; 829 return false; //break 830 } 831 }); 832 } 833 showItem.categoryId = categoryId; 834 835 showItem.name = "Show Item " + ($scope.show.showItems.length + 1); 836 showItem.categoryFieldsValues = []; 837 showItem.published = false; 838 showItem.active = true; 839 840 showsService.upsertShowItemByOwner(showItem).then(function (results) { 841 842 // Get the show item returned ready for display 843 var returnedShowItem = results.data.showItems[0]; 844 $scope.prepareShowItemForDisplay(returnedShowItem); 845 846 // Push the new show item onto the existing show 847 $scope.show.showItems.push(returnedShowItem); 848 849 // Go to the last page (if the number of items is divided exactly by page size, add one to the page) 850 if ($scope.show.showItems.length % $scope.pageSize == 0) { 851 $scope.pageNumber = Math.ceil($scope.show.showItems.length / $scope.pageSize) + 1; 852 } else { 853 $scope.pageNumber = Math.ceil($scope.show.showItems.length / $scope.pageSize); 854 } 855 856 if (scrollToBottom) { 857 // TODO: Should we check to see if the scroll position is within the window.innerHeight and if so, not scroll ? 858 $('html, body').animate({ scrollTop: $("#bottomOfShowItems").offset().top - (window.innerHeight / 2) }, 500); 859 } 860 861 // Expand the show item that was just created 862 $scope.toggleExpanded(returnedShowItem); 863 864 $scope.loadPaymentDirectiveDate = new Date(); //By setting this variable, it'll cause the payment directive to load (or re-load) 865 866 deferred.resolve(); 867 868 }, function (error) { 869 popApiErrorMessage(error); 870 deferred.resolve(); 871 }); 872 873 return deferred.promise; 874 875 }; 876 877 $scope.toggleShowItemActiveByOwner = function (showItem) { 878 var deferred = $q.defer(); 879 880 showsService.toggleShowItemActiveByOwner(showItem.showId, showItem.showItemId).then(function (results) { 881 882 showItem.active = !showItem.active; 883 884 if (showItem.active) { 885 popMessage("success", "Show Item Successfully Activated", "The show item has been successfully activated."); 886 } else { 887 // Remove the show item from the show 888 var foundIndex = -1; 889 $.each($scope.show.showItems, function (itemIndex, itemValue) { 890 if (itemValue.showItemId == showItem.showItemId) { 891 foundIndex = itemIndex; 892 return false; 893 } 894 }); 895 $scope.show.showItems.splice(foundIndex, 1); 896 popMessage("success", "Show Item Successfully Deleted", "The show item has been successfully deleted."); 897 } 898 899 // Recalc the unpublished for the tab 900 $scope.$parent.calculateUnpublishedCount(); 901 902 $scope.loadPaymentDirectiveDate = new Date(); //By setting this variable, it'll cause the payment directive to load (or re-load) 903 904 deferred.resolve(); 905 }, function (error) { 906 popApiErrorMessage(error); 907 deferred.resolve(); 908 }); 909 910 return deferred.promise; 911 }; 912 913 $scope.adminPaymentMade = $rootScope.$on('show-items-payment-made', function (event, showItemIds) { 914 $scope.getShow(); 915 }); 916 917 /*********************************************************************************************************************** 918 919 Table sorting and paging methods 920 921 */ 922 923 $scope.pageSizeFilter = function (val) { 924 return function (item) { 925 return item['id'] <= val; 926 } 927 }; 928 929 $scope.pageResults = function (pagination) { 930 $scope.pageNumber = pagination.page; 931 932 // Set the values in the query string 933 $scope.setQueryStringSearchParams(); 934 935 $scope.expandedShowItemId = 0; 936 }; 937 938 $scope.pageSizeChange = function (newpageSize) { 939 $scope.pageSize = newpageSize; 940 941 // Set the values in the query string 942 $scope.setQueryStringSearchParams(); 943 944 $scope.expandedShowItemId = 0; 945 }; 946 947 $scope.setQueryStringSearchParams = function () { 948 949 $location.search($scope.queryStringPrefix + "ft", $scope.filter.text); // CUSTOM PER CONTROLLER 950 $location.search($scope.queryStringPrefix + "fs", $scope.filter.status); // CUSTOM PER CONTROLLER 951 952 $location.search($scope.queryStringPrefix + "p", $scope.pageNumber); 953 $location.search($scope.queryStringPrefix + "ps", $scope.pageSize); 954 $location.search($scope.queryStringPrefix + "s", $scope.sortField); 955 $location.search($scope.queryStringPrefix + "sd", $scope.sortDirection); 956 }; 957 958 $scope.getQueryStringSearchParams = function () { 959 960 if (getParameterByName($scope.queryStringPrefix + "ft").length > 0) { // CUSTOM PER CONTROLLER 961 $scope.filter.text = getParameterByName($scope.queryStringPrefix + "ft"); 962 } 963 964 if (getParameterByName($scope.queryStringPrefix + "fs").length > 0) { // CUSTOM PER CONTROLLER 965 $scope.filter.status = getParameterByName($scope.queryStringPrefix + "fs"); 966 } 967 968 if (getParameterByName($scope.queryStringPrefix + "p").length > 0) { 969 $scope.pageNumber = Number(getParameterByName($scope.queryStringPrefix + "p")); 970 } 971 if (getParameterByName($scope.queryStringPrefix + "ps").length > 0) { 972 $scope.pageSize = Number(getParameterByName($scope.queryStringPrefix + "ps")); 973 } 974 if (getParameterByName($scope.queryStringPrefix + "s").length > 0) { 975 $scope.sortField = getParameterByName($scope.queryStringPrefix + "s"); 976 } 977 if (getParameterByName($scope.queryStringPrefix + "sd").length > 0) { 978 $scope.sortDirection = getParameterByName($scope.queryStringPrefix + "sd"); 979 } 980 981 }; 982 983 $scope.checkIfFilterChanged = function () { 984 if ($scope.filterChanged) { 985 $scope.pageNumber = 1; 986 $scope.filterChanged = false; 987 } 988 }; 989 990 // Set the default variables 991 $scope.availablePageSizes = lists.availablePageSizes;
992 993 $scope.queryStringPrefix = 'sregi-'; // CUSTOM PER CONTROLLER 994 995 $scope.pageNumber = 1; 996 $scope.pageSize = 25; 997 998 $scope.filter = { 999 text: '', 1000 }; // CUSTOM PER CONTROLLER 1001 1002 $scope.isSearchInProgress = false; 1003 $scope.filterChanged = false; 1004 1005 // Check to see if any values got passed in the query string 1006 $scope.getQueryStringSearchParams(); 1007 1008 /* 1009 1010 End table sorting and paging methods 1011 1012 ***********************************************************************************************************************/ 1013 1014 1015 $scope.checkVideoSrc = function (showItem) { 1016 showItem.newVideoEmbed = checkVideoSrc(showItem.newVideoEmbed); 1017 }; 1018 1019 $scope.saveNote = function (showItem) { 1020 $scope.saveShowItem(showItem, null); 1021 }; 1022 1023 $scope.addGridContentRow = function (showItem, categoryField) { 1024 if (categoryField.gridContent == null) { 1025 categoryField.gridContent = { 1026 rows: [] 1027 }; 1028 } 1029 1030 var newRow = { columns: [] }; 1031 1032 //Add the appropriate number of columns 1033 if (categoryField.gridContent.rows.length > 0) { 1034 $.each(categoryField.gridContent.rows[0].columns, function (index, column) { 1035 newRow.columns.push($scope.getColumnBase()); 1036 }); 1037 columnCount = categoryField.gridContent.rows[0].columns.length; 1038 } else { 1039 //this is the first row, so just add one column to it 1040 newRow.columns.push($scope.getColumnBase()); 1041 } 1042 1043 categoryField.gridContent.rows.push(newRow); 1044 1045 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1046 }; 1047 1048 $scope.addGridContentColumn = function (showItem, categoryField) { 1049 if (categoryField.gridContent == null) { 1050 $scope.addGridContentRow(categoryField); 1051 } else { 1052 $.each(categoryField.gridContent.rows, function (index, row) { 1053 row.columns.push($scope.getColumnBase()); 1054 }); 1055 } 1056 1057 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1058 }; 1059 1060 $scope.removeGridContentColumn = function (showItem, categoryField, columnIndex) { 1061 $.each(categoryField.gridContent.rows, function (index, row) { 1062 row.columns.splice(columnIndex, 1); 1063 }); 1064 1065 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1066 }; 1067 1068 $scope.removeGridContentRow = function (showItem, categoryField, rowIndex) { 1069 categoryField.gridContent.rows.splice(rowIndex, 1); 1070 1071 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1072 }; 1073 1074 $scope.setAllBorders = function (showItem, categoryField, isShowing) { 1075 1076 $.each(categoryField.gridContent.rows, function (rowIndex, row) { 1077 $.each(row.columns, function (columnIndex, column) { 1078 if (column.borders == null) { 1079 column.borders = { 1080 top: false, 1081 right: false, 1082 bottom: false, 1083 left: false 1084 }; 1085 } 1086 1087 column.borders.top = isShowing; 1088 column.borders.right = isShowing; 1089 column.borders.bottom = isShowing; 1090 column.borders.left = isShowing; 1091 }); 1092 }); 1093 1094 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1095 }; 1096 1097 $scope.toggleColumnBorder = function (showItem, categoryField, columnBorders, whichBorder) { 1098 switch (whichBorder) { 1099 case 'top': 1100 columnBorders.top = !columnBorders.top; 1101 break; 1102 case 'right': 1103 columnBorders.right = !columnBorders.right; 1104 break; 1105 case 'bottom': 1106 columnBorders.bottom = !columnBorders.bottom; 1107 break; 1108 case 'left': 1109 columnBorders.left = !columnBorders.left; 1110 break; 1111 } 1112
1113 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1114 }; 1115 1116 $scope.setColumnBorders = function (showItem, categoryField, columnBorders, isShowing) { 1117 columnBorders.top = isShowing; 1118 columnBorders.right = isShowing; 1119 columnBorders.bottom = isShowing; 1120 columnBorders.left = isShowing; 1121 1122 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1123 }; 1124 1125 $scope.setColumnBackroundColor = function (showItem, categoryField, column, className) { 1126 column.bgClass = className; 1127 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1128 }; 1129 1130 $scope.getColumnBase = function () { 1131 return { 1132 bgClass: '', 1133 text: '', 1134 borders: { 1135 top: false, 1136 right: false, 1137 bottom: false, 1138 left: false 1139 } 1140 }; 1141 }; 1142 1143 $scope.setGridTemplate = function (showItem, categoryField, newGridTemplateId) { 1144 switch (newGridTemplateId) { 1145 case 0: 1146 categoryField.gridContent = { 1147 "showGridlines": false, 1148 "maxWidth": null, 1149 rows: [] 1150 }; 1151 break; 1152 case 1: 1153 categoryField.gridContent = { 1154 "showGridlines": false, 1155 "maxWidth": null, 1156 "rows": [ 1157 { 1158 "columns": [ 1159 { 1160 "bgClass": "", 1161 "textClass": "", 1162 "text": "", 1163 "borders": { 1164 "top": false, 1165 "right": false, 1166 "bottom": false, 1167 "left": false 1168 } 1169 }, 1170 { 1171 "bgClass": "", 1172 "textClass": "", 1173 "text": "", 1174 "borders": { 1175 "top": false, 1176 "right": false, 1177 "bottom": false, 1178 "left": false 1179 } 1180 } 1181 ] 1182 }, 1183 { 1184 "columns": [ 1185 { 1186 "bgClass": "", 1187 "textClass": "", 1188 "text": "", 1189 "borders": { 1190 "top": false, 1191 "right": false, 1192 "bottom": false, 1193 "left": false 1194 } 1195 }, 1196 { 1197 "bgClass": "", 1198 "textClass": "", 1199 "text": "", 1200 "borders": { 1201 "top": false, 1202 "right": false, 1203 "bottom": false, 1204 "left": false 1205 } 1206 } 1207 ] 1208 } 1209 ] 1210 } 1211 1212 break; 1213 case 2: 1214 categoryField.gridContent = { 1215 "showGridlines": false, 1216 "maxWidth": null, 1217 "rows": [ 1218 { 1219 "columns": [ 1220 { 1221 "bgClass": "", 1222 "textClass": "", 1223 "text": "", 1224 "borders": { 1225 "top": false, 1226 "right": false, 1227 "bottom": false, 1228 "left": false 1229 } 1230 }, 1231 { 1232 "bgClass": "", 1233 "textClass": "", 1234 "text": "", 1235 "borders": { 1236 "top": false, 1237 "right": false, 1238 "bottom": false, 1239 "left": false 1240 } 1241 }, 1242 { 1243 "bgClass": "", 1244 "textClass": "", 1245 "text": "", 1246 "borders": { 1247 "top": false, 1248 "right": false, 1249 "bottom": false, 1250 "left": false 1251 } 1252 }, 1253 { 1254 "bgClass": "", 1255 "textClass": "", 1256 "text": "", 1257 "borders": { 1258 "top": false, 1259 "right": false, 1260 "bottom": false, 1261 "left": false 1262 } 1263 } 1264 ] 1265 }, 1266 { 1267 "columns": [ 1268 { 1269 "bgClass": "", 1270 "textClass": "", 1271 "text": "", 1272 "borders": { 1273 "top": false, 1274 "right": false, 1275 "bottom": false, 1276 "left": false 1277 } 1278 }, 1279 { 1280 "bgClass": "", 1281 "textClass": "", 1282 "text": "", 1283 "borders": { 1284 "top": false, 1285 "right": false, 1286 "bottom": false, 1287 "left": false 1288 } 1289 }, 1290 { 1291 "bgClass": "", 1292 "textClass": "", 1293 "text": "", 1294 "borders": { 1295 "top": false, 1296 "right": false, 1297 "bottom": false, 1298 "left": false 1299 } 1300 }, 1301 { 1302 "bgClass": "", 1303 "textClass": "", 1304 "text": "", 1305 "borders": { 1306 "top": false, 1307 "right": false, 1308 "bottom": false, 1309 "left": false 1310 } 1311 } 1312 ] 1313 }, 1314 { 1315 "columns": [ 1316 { 1317 "bgClass": "", 1318 "textClass": "", 1319 "text": "", 1320 "borders": { 1321 "top": false, 1322 "right": false, 1323 "bottom": false, 1324 "left": false 1325 } 1326 }, 1327 { 1328 "bgClass": "", 1329 "textClass": "", 1330 "text": "", 1331 "borders": { 1332 "top": false, 1333 "right": false, 1334 "bottom": false, 1335 "left": false 1336 } 1337 }, 1338 { 1339 "bgClass": "", 1340 "textClass": "", 1341 "text": "", 1342 "borders": { 1343 "top": false, 1344 "right": false, 1345 "bottom": false, 1346 "left": false 1347 } 1348 }, 1349 { 1350 "bgClass": "", 1351 "textClass": "", 1352 "text": "", 1353 "borders": { 1354 "top": false, 1355 "right": false, 1356 "bottom": false, 1357 "left": false 1358 } 1359 } 1360 ] 1361 }, 1362 { 1363 "columns": [ 1364 { 1365 "bgClass": "", 1366 "textClass": "", 1367 "text": "", 1368 "borders": { 1369 "top": false, 1370 "right": false, 1371 "bottom": false, 1372 "left": false 1373 } 1374 }, 1375 { 1376 "bgClass": "", 1377 "textClass": "", 1378 "text": "", 1379 "borders": { 1380 "top": false, 1381 "right": false, 1382 "bottom": false, 1383 "left": false 1384 } 1385 }, 1386 { 1387 "bgClass": "", 1388 "textClass": "", 1389 "text": "", 1390 "borders": { 1391 "top": false, 1392 "right": false, 1393 "bottom": false, 1394 "left": false 1395 } 1396 }, 1397 { 1398 "bgClass": "", 1399 "textClass": "", 1400 "text": "", 1401 "borders": { 1402 "top": false, 1403 "right": false, 1404 "bottom": false, 1405 "left": false 1406 } 1407 } 1408 ] 1409 } 1410 ] 1411 } 1412 1413 break; 1414 case 3: 1415 categoryField.gridContent = { 1416 "showGridlines": false, 1417 "maxWidth": null, 1418 "rows": [ 1419 { 1420 "columns": [ 1421 { 1422 "bgClass": "", 1423 "textClass": "", 1424 "text": "", 1425 "borders": { 1426 "top": false, 1427 "right": false, 1428 "bottom": false, 1429 "left": false 1430 } 1431 }, 1432 { 1433 "bgClass": "", 1434 "textClass": "", 1435 "text": "", 1436 "borders": { 1437 "top": false, 1438 "right": false, 1439 "bottom": false, 1440 "left": false 1441 } 1442 }, 1443 { 1444 "bgClass": "bg-success", 1445 "textClass": "", 1446 "text": "SIRE:", 1447
1447 "borders": { 1448 "top": true, 1449 "right": true, 1450 "bottom": true, 1451 "left": true 1452 } 1453 } 1454 ] 1455 }, 1456 { 1457 "columns": [ 1458 { 1459 "bgClass": "", 1460 "textClass": "", 1461 "text": "", 1462 "borders": { 1463 "top": false, 1464 "right": false, 1465 "bottom": false, 1466 "left": false 1467 } 1468 }, 1469 { 1470 "bgClass": "bg-success", 1471 "textClass": "", 1472 "text": "SIRE:", 1473 "borders": { 1474 "top": true, 1475 "right": true, 1476 "bottom": true, 1477 "left": true 1478 } 1479 }, 1480 { 1481 "bgClass": "", 1482 "textClass": "", 1483 "text": "", 1484 "borders": { 1485 "top": false, 1486 "right": false, 1487 "bottom": false, 1488 "left": false 1489 } 1490 } 1491 ] 1492 }, 1493 { 1494 "columns": [ 1495 { 1496 "bgClass": "", 1497 "textClass": "", 1498 "text": "", 1499 "borders": { 1500 "top": false, 1501 "right": true, 1502 "bottom": false, 1503 "left": false 1504 } 1505 }, 1506 { 1507 "bgClass": "", 1508 "textClass": "", 1509 "text": "", 1510 "borders": { 1511 "top": false, 1512 "right": false, 1513 "bottom": false, 1514 "left": false 1515 } 1516 }, 1517 { 1518 "bgClass": "bg-warning", 1519 "textClass": "", 1520 "text": "DAM:", 1521 "borders": { 1522 "top": true, 1523 "right": true, 1524 "bottom": true, 1525 "left": true 1526 } 1527 } 1528 ] 1529 }, 1530 { 1531 "columns": [ 1532 { 1533 "bgClass": "bg-success", 1534 "textClass": "", 1535 "text": "SIRE:", 1536 "borders": { 1537 "top": true, 1538 "right": true, 1539 "bottom": true, 1540 "left": true 1541 } 1542 }, 1543 { 1544 "bgClass": "", 1545 "textClass": "", 1546 "text": "", 1547 "borders": { 1548 "top": false, 1549 "right": false, 1550 "bottom": false, 1551 "left": false 1552 } 1553 }, 1554 { 1555 "bgClass": "", 1556 "textClass": "", 1557 "text": "", 1558 "borders": { 1559 "top": false, 1560 "right": false, 1561 "bottom": false, 1562 "left": false 1563 } 1564 } 1565 ] 1566 }, 1567 { 1568 "columns": [ 1569 { 1570 "bgClass": "", 1571 "textClass": "", 1572 "text": "", 1573 "borders": { 1574 "top": false, 1575 "right": true, 1576 "bottom": false, 1577 "left": false 1578 } 1579 }, 1580 { 1581 "bgClass": "", 1582 "textClass": "", 1583 "text": "", 1584 "borders": { 1585 "top": false, 1586 "right": false, 1587 "bottom": false, 1588 "left": false 1589 } 1590 }, 1591 { 1592 "bgClass": "bg-success", 1593 "textClass": "", 1594 "text": "SIRE:", 1595 "borders": { 1596 "top": true, 1597 "right": true, 1598 "bottom": true, 1599 "left": true 1600 } 1601 } 1602 ] 1603 }, 1604 { 1605 "columns": [ 1606 { 1607 "bgClass": "", 1608 "textClass": "", 1609 "text": "", 1610 "borders": { 1611 "top": false, 1612 "right": false, 1613 "bottom": false, 1614 "left": false 1615 } 1616 }, 1617 { 1618 "bgClass": "bg-warning", 1619 "textClass": "", 1620 "text": "DAM:", 1621 "borders": { 1622 "top": true, 1623 "right": true, 1624 "bottom": true, 1625 "left": true 1626 } 1627 }, 1628 { 1629 "bgClass": "", 1630 "textClass": "", 1631 "text": "", 1632 "borders": { 1633 "top": false, 1634 "right": false, 1635 "bottom": false, 1636 "left": false 1637 } 1638 } 1639 ] 1640 }, 1641 { 1642 "columns": [ 1643 { 1644 "bgClass": "", 1645 "textClass": "", 1646 "text": "", 1647 "borders": { 1648 "top": false, 1649 "right": false, 1650 "bottom": false, 1651 "left": false 1652 } 1653 }, 1654 { 1655 "bgClass": "", 1656 "textClass": "", 1657 "text": "", 1658 "borders": { 1659 "top": false, 1660 "right": false, 1661 "bottom": false, 1662 "left": false 1663 } 1664 }, 1665 { 1666 "bgClass": "bg-warning", 1667 "textClass": "", 1668 "text": "DAM:", 1669 "borders": { 1670 "top": true, 1671 "right": true, 1672 "bottom": true, 1673 "left": true 1674 } 1675 } 1676 ] 1677 }, 1678 { 1679 "columns": [ 1680 { 1681 "bgClass": "", 1682 "textClass": "", 1683 "text": "", 1684 "borders": { 1685 "top": false, 1686 "right": false, 1687 "bottom": false, 1688 "left": false 1689 } 1690 }, 1691 { 1692 "bgClass": "", 1693 "textClass": "", 1694 "text": "", 1695 "borders": { 1696 "top": false, 1697 "right": false, 1698 "bottom": false, 1699 "left": false 1700 } 1701 }, 1702 { 1703 "bgClass": "", 1704 "textClass": "", 1705 "text": "", 1706 "borders": { 1707 "top": false, 1708 "right": false, 1709 "bottom": false, 1710 "left": false 1711 } 1712 } 1713 ] 1714 }, 1715 { 1716 "columns": [ 1717 { 1718 "bgClass": "", 1719 "textClass": "", 1720 "text": "", 1721 "borders": { 1722 "top": false, 1723 "right": false, 1724 "bottom": false, 1725 "left": false 1726 } 1727 }, 1728 { 1729 "bgClass": "", 1730 "textClass": "", 1731 "text": "", 1732 "borders": { 1733 "top": false, 1734 "right": false, 1735 "bottom": false, 1736 "left": false 1737 } 1738 }, 1739 { 1740 "bgClass": "bg-success", 1741 "textClass": "", 1742 "text": "SIRE:", 1743 "borders": { 1744 "top": true, 1745 "right": true, 1746 "bottom": true, 1747 "left": true 1748 } 1749 } 1750 ] 1751 }, 1752 { 1753 "columns": [ 1754 { 1755 "bgClass": "", 1756 "textClass": "", 1757 "text": "", 1758 "borders": { 1759 "top": false, 1760 "right": false, 1761 "bottom": false, 1762 "left": false 1763 } 1764 }, 1765 { 1766
1766 "bgClass": "bg-success", 1767 "textClass": "", 1768 "text": "SIRE:", 1769 "borders": { 1770 "top": true, 1771 "right": true, 1772 "bottom": true, 1773 "left": true 1774 } 1775 }, 1776 { 1777 "bgClass": "", 1778 "textClass": "", 1779 "text": "", 1780 "borders": { 1781 "top": false, 1782 "right": false, 1783 "bottom": false, 1784 "left": false 1785 } 1786 } 1787 ] 1788 }, 1789 { 1790 "columns": [ 1791 { 1792 "bgClass": "", 1793 "textClass": "", 1794 "text": "", 1795 "borders": { 1796 "top": false, 1797 "right": true, 1798 "bottom": false, 1799 "left": false 1800 } 1801 }, 1802 { 1803 "bgClass": "", 1804 "textClass": "", 1805 "text": "", 1806 "borders": { 1807 "top": false, 1808 "right": false, 1809 "bottom": false, 1810 "left": false 1811 } 1812 }, 1813 { 1814 "bgClass": "bg-warning", 1815 "textClass": "", 1816 "text": "DAM:", 1817 "borders": { 1818 "top": true, 1819 "right": true, 1820 "bottom": true, 1821 "left": true 1822 } 1823 } 1824 ] 1825 }, 1826 { 1827 "columns": [ 1828 { 1829 "bgClass": "bg-warning", 1830 "textClass": "", 1831 "text": "DAM:", 1832 "borders": { 1833 "top": true, 1834 "right": true, 1835 "bottom": true, 1836 "left": true 1837 } 1838 }, 1839 { 1840 "bgClass": "", 1841 "textClass": "", 1842 "text": "", 1843 "borders": { 1844 "top": false, 1845 "right": false, 1846 "bottom": false, 1847 "left": false 1848 } 1849 }, 1850 { 1851 "bgClass": "", 1852 "textClass": "", 1853 "text": "", 1854 "borders": { 1855 "top": false, 1856 "right": false, 1857 "bottom": false, 1858 "left": false 1859 } 1860 } 1861 ] 1862 }, 1863 { 1864 "columns": [ 1865 { 1866 "bgClass": "", 1867 "textClass": "", 1868 "text": "", 1869 "borders": { 1870 "top": false, 1871 "right": true, 1872 "bottom": false, 1873 "left": false 1874 } 1875 }, 1876 { 1877 "bgClass": "", 1878 "textClass": "", 1879 "text": "", 1880 "borders": { 1881 "top": false, 1882 "right": false, 1883 "bottom": false, 1884 "left": false 1885 } 1886 }, 1887 { 1888 "bgClass": "bg-success", 1889 "textClass": "", 1890 "text": "SIRE:", 1891 "borders": { 1892 "top": true, 1893 "right": true, 1894 "bottom": true, 1895 "left": true 1896 } 1897 } 1898 ] 1899 }, 1900 { 1901 "columns": [ 1902 { 1903 "bgClass": "", 1904 "textClass": "", 1905 "text": "", 1906 "borders": { 1907 "top": false, 1908 "right": false, 1909 "bottom": false, 1910 "left": false 1911 } 1912 }, 1913 { 1914 "bgClass": "bg-warning", 1915 "textClass": "", 1916 "text": "DAM:", 1917 "borders": { 1918 "top": true, 1919 "right": true, 1920 "bottom": true, 1921 "left": true 1922 } 1923 }, 1924 { 1925 "bgClass": "", 1926 "textClass": "", 1927 "text": "", 1928 "borders": { 1929 "top": false, 1930 "right": false, 1931 "bottom": false, 1932 "left": false 1933 } 1934 } 1935 ] 1936 }, 1937 { 1938 "columns": [ 1939 { 1940 "bgClass": "", 1941 "textClass": "", 1942 "text": "", 1943 "borders": { 1944 "top": false, 1945 "right": false, 1946 "bottom": false, 1947 "left": false 1948 } 1949 }, 1950 { 1951 "bgClass": "", 1952 "textClass": "", 1953 "text": "", 1954 "borders": { 1955 "top": false, 1956 "right": false, 1957 "bottom": false, 1958 "left": false 1959 } 1960 }, 1961 { 1962 "bgClass": "bg-warning", 1963 "textClass": "", 1964 "text": "DAM:", 1965 "borders": { 1966 "top": true, 1967 "right": true, 1968 "bottom": true, 1969 "left": true 1970 } 1971 } 1972 ] 1973 } 1974 ] 1975 } 1976 1977 break; 1978 } 1979
1980 $scope.saveCategoryField(showItem, categoryField, showItem.showItemId + '_categoryField_' + categoryField.categoryFieldId); 1981 }; 1982 1983 $scope.isInRole = function (roleName) { 1984 var roles = [] 1985 1986 if ($scope.user && $scope.user != null && $scope.user.roles && $scope.user.roles != null) { 1987 roles = $scope.user.roles.split(','); 1988 } 1989 1990 var foundRole = false; 1991 1992 $.each(roles, function (index, role) { 1993 if ($.trim(roleName).toLowerCase() == $.trim(role).toLowerCase()) { 1994 foundRole = true; 1995 return false; 1996 } 1997 }); 1998 1999 return foundRole; 2000 }; 2001 2002 $scope.formatDateAsUtc = function (dateToFormat) { 2003 return formatDateOrDateStringAsUtcDate(dateToFormat); 2004 }; 2005 2006 $scope.returnToShow = function () { 2007 $state.go('show', { "showId": $scope.showId }); 2008 }; 2009 2010 $scope.notCompletedRegistrations = function () { 2011 let incompleteRegistrationExists = false; 2012 $.each($scope.show.showItems, function (showItemIndex, showItem) { 2013 if (!showItem.registrationComplete) { 2014 incompleteRegistrationExists = true; 2015 return; 2016 } 2017 }); 2018 return incompleteRegistrationExists; 2019 }; 2020 2021 $scope.completeRegistration = function () { 2022 var deferred = $q.defer(); 2023 2024 $.each($scope.show.showItems, function (showItemIndex, showItem) { 2025 if (!showItem.registrationComplete) { 2026 showsService.completeRegistration(showItem.showId, showItem.showItemId).then(function (results) { 2027 2028 showItem.registrationComplete = true; 2029 2030 if (!$scope.notCompletedRegistrations()) { 2031 popMessage("success", "Registration Complete", 'All show items have been registered.'); 2032 deferred.resolve(); 2033 } 2034 2035 }, function (error) { 2036 popApiErrorMessage(error); 2037 deferred.resolve(); 2038 }); 2039 } 2040 }); 2041 2042 return deferred.promise; 2043 }; 2044 2045 2046 //initialize variables 2047 $scope.pageIsLoaded = false; 2048 $scope.user = localStorageService.get('AuthData'); 2049 2050 $scope.show = { showId: -1, consignors: [], showItems: [], displayOneShowItemCategoryFieldPerRow: false, showCategoryTags: [] }; 2051 2052 $scope.showId = $stateParams.showId; 2053 $scope.states = lists.states; 2054 2055 $scope.includeDirectPaymentTypes = false; 2056 2057 $scope.loadPaymentDirectiveDate = new Date(); //By setting this variable, it'll cause the payment directive to load (or re-load) 2058 2059 2060 // Set the category field names for calculations 2061 $scope.weightFieldNames = ['weight', 'wt']; 2062 $scope.birthDateFieldNames = ['birth_date', 'birth_day', 'date_of_birth', 'dob', 'far_date', 'farrowing_date']; 2063 $scope.birthWeightFieldNames = ['birth_weight', 'weight_at_birth', 'bwt', 'wab']; 2064 $scope.weightPerDayFieldNames = ['weight/day', 'weight_/_day', 'weight_per_day', 'wda']; 2065 2066 $scope.someFieldsEditable = false; 2067 2068 2069 //initialize Page 2070 $scope.initializePage(); 2071 } 2072]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.