Customizing Column Background Color with AngularJS

https://i.sstatic.net/OHFFF.png

My current webapp highlights the day of the week on a table for the current day and the day two weeks from now. However, I'm facing an issue with adjusting the highlight if either of these days falls on a holiday. Currently, the holiday highlight (purple) is overriding the yellow highlight, but I need the yellow highlight to show up for 7/5 as 7/4 is a holiday.

The business rule behind these highlighting rules is that the first day and the last day of a 10-day period will be highlighted in yellow. If either the first or last day falls on a holiday, the highlight needs to shift to the next day.

I could use some guidance on how to achieve this adjustment. I don't require a complete answer, just a push in the right direction would be helpful.

Index.html

<html>
  <head>
    <link rel="stylesheet" type="text/css" media="all" href="app.css" />
      <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
      <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">
    <script src="js/angular.js"></script>
    <script src="js/angular-route.js"></script>
    <script src="js/domo.js"></script>
    <script src="js/app.js"></script>      
  </head>
  <body ng-app="rcr_sched" ng-controller="main">
      <div id="mydiv">
        <table>
            <tr id="printc"><button id="print" class="fa fa-print fa-3x" onclick="print('#mydiv')"></button>
            <button id="print2" onclick="print('#mydiv')">Print Page</button>
            <button id="today">Today/SLDD</button>
            <button id="PTO">PTO</button>
            <button id="Hol">Hol</button>
            </tr>
            <tr height="40" id="header">
                <th ng-repeat="prop in columns">{{prop.date}}</th>
            </tr>  
            <tr ng-repeat="r in data">
                <td align="center" ng-repeat="prop2 in columns" class="{{getColor(r.TeamRank, r.Team, prop2.title)}}" style="{{isPTO(prop2.title, 'PTO' + prop2.title, r['PTO' + prop2.title]) || isHol(prop2.title, 'Hol' + prop2.title, r['Hol' + prop2.title])}}">
                    {{r[prop2.title]}}
                </td>
            </tr>
        </table>
          <hr id="end">
      </div>      
  </body>
</html>

App.js

var app = angular.module('rcr_sched',['ngRoute']);

 app.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider
       .when('/',{
           templateUrl:'index.html',
           controller:'main'
       })
       .when('drill',{
           templateUrl:'drill.html'
       })
//       .otherwise({redirectTo: '/'});  
    }
 ]);
//Range Error: Maximum call stack size exceeded

app.controller('main', ['$scope', '$location', function ($scope, $location){
        $scope.goNext = function(view){
            $location.path('/');
        }
        $scope.data = [];
        $scope.columns = [];
        $... (Remaining content shortened due to space limitations)
});

App.css

body{
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    font-size: xx-small;
    -webkit-print-color-adjust: exact;
    -moz-print-color-adjust: exact;
}

a{
    color: black;
    text-align: center;
    padding-left: 15px
}

... (Remaining content shortened for brevity)

@media print{
    #print{
        display: none;
    }

    #print2{
        display: none;
    }

    #link{
        display: none;
    }

}

Answer №1

After some consideration, I decided to make adjustments to my if statements that were responsible for the yellow highlighting feature. Here is how they currently appear:

if(prop == 'Tue2Wks')
            {
                if(today.getDay() == 1 && prop.HolMon2Wks !== null)
                {
                 return "highlightClass";
                }
                else if(today.getDay() == 2 && prop.HolTue2Wks !== null)
                {
                    return '';
                }
                else if(today.getDay() == 2)
                {
                    return "highlightClass";
                }
            }

It should be noted that each statement is customized based on the specific day of the week.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Calculate the total amount by multiplying the price and quantity values within nested arrays

I have a collection of objects with nested arrays structured like this [ { orderId: 123, orderStatus: 'Pending', date: 'June 13, 2020', products: [ {product: 'choco', price: 300, qty: 3}, {product: 'm ...

Utilize GetXmlHttpObject for an AJAX request to interact with a PHP script

I am currently attempting to call a PHP file using the GetXmlHttpObject object and so far, I have had some progress. However, it seems that there is an issue with the URL variable. Do I need to handle the URL string in a different way? Here is the releva ...

I'm facing issues with Angular commands not functioning properly even after installing the Angular CLI and configuring the

Every time I attempt to create a new project using Angular CLI by typing: ng n app I encounter the following error message: C:\Users\Venkateshwarn M\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng: ...

Using await outside of an async function is not allowed

When working with a rest api in node.js, I have implemented functionality to automatically resize any uploaded images that are too large. However, I am encountering an error when trying to call my await method. Here is the code snippet: ': await is o ...

Error: Value not defined in the (Node, Express, Pug, JQuery) environment

I'm encountering a common issue as a beginner and could really use some assistance. I have tried multiple solutions but still can't resolve the error "ReferenceError: $ is not defined" when attempting to use jQuery. My project structure looks lik ...

Tips for invoking a url with JavaScript and retrieving the response back to JavaScript

I am trying to make a URL call from JavaScript with a single parameter, and the URL should respond to that specific request. Here is an example of the response format: {"success":true, "result": {"token":"4fc5ef2bd77a3","serverTime":1338371883,"expireT ...

Build a custom form for the purpose of exporting an HTML file

I am in search of a way to provide my users with various "feature" choices that will assist them in creating an HTML file for an email. I already have the code ready for each feature, but I want users to be able to select a feature (such as Hero Image Head ...

When refreshing the page, redux-persist clears the state

I have integrated redux-persist into my Next.js project. The issue I am facing is that the state is getting saved in localStorage when the store is updated, but it gets reset every time the page changes. I suspect the problem lies within one of the reducer ...

A peaceful WCF service initiates a client callback whenever a server update occurs

In the process of developing a WCF RESTFUL service on top of a c++ console application, I am confronted with an issue. The client accesses this c++ application through my restful wcf service using a browser. Every time there is an update received by my w ...

Is there a way to asynchronously load image src URLs in Vue.js?

Why is the image URL printing in console but not rendering to src attribute? Is there a way to achieve this using async and await in Vue.js? <div v-for="(data, key) in imgURL" :key="key"> <img :src= "fetchImage(data)" /> </div> The i ...

Implementing file uploads in an Ionic application with a Web API

My dilemma is as follows: I am working with a WEB API where I need to upload images of boards. What do I need to do? Allow the user to select an image from their phone Enable the user to add a name for the board When the user clicks submit, the entered ...

Unable to modify jwplayer css styles to customize the chromecast icon

Is there a way to customize the chromecast icon within the JWPlayer skin to have a specific color? I've identified that the styles I need to change are --connected-color and disconnected-color when inspecting the element. Despite my attempts through ...

Error encountered in NodeJS: Promise TypeError - res.json is not a function while handling pre-signed URLs. This results in

I'm having trouble generating a list of pre-signed URLs for files in my private S3 bucket. Despite researching similar issues on multiple forums, I can't seem to resolve the error with the res.json function in my code. Can someone please help me ...

Struggling to implement sparklines for real-time data in the AngularJS adaptation of the SmartAdmin template

Currently, I am embarking on a project that involves utilizing the AngularJS version of the SmartAdmin Bootstrap template foundhere. Within this project scope, I am required to integrate sparklines into various pages. I have successfully implemented them ...

Utilizing Django fixtures: Importing HTML content as JSON into a Text Field

Currently in the process of transitioning my website to Django from another content management system, I am facing challenges with importing HTML into Django using fixtures. The specific issue revolves around "Events", which is a model within my Django app ...

Chic and perfectly aligned stripe button design

I need assistance with centering and styling the Stripe checkout button labeled "update card." Additionally, I want to adjust the appearance of the card number input field to be normal but readonly. How can I achieve this without relying on Bootstrap' ...

Retrieve all elements from JSON using jQuery

JavaScript: function loadDoc(url) { $.ajax({ url: 'mytestjson', dataType: 'json', cache: false }).success(function (result) { console.log(result); //var txt = result.newBranches[0].newNon ...

Discover content within nested arrays - angularJS

I have a function written in angularJS that utilizes find to verify the presence of an item in an array; function checkCartItem(item) { return $scope.cart[0].cart_items.find(function(itm) { return itm.item_id === item.item_id }); } The fu ...

The npm package for google-spreadsheet.js is experiencing issues and is not functioning correctly when trying to replicate the GitHub

After attempting to implement the basic example code provided at https://github.com/theoephraim/node-google-spreadsheet, I encountered an issue. For instance: const { GoogleSpreadsheet } = require('google-spreadsheet') const creds = require(&apo ...

Adjust the sizing of all fonts following the switch in font styles

Seeking help for adjusting font-size across a responsive web page design using different font families. font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif; To achieve responsiveness, various media queries were applie ...