JeanBenitez 1 năm trước cách đây
mục cha
commit
e1f3eca8c3

+ 194 - 0
sistema-mantenimiento-front/src/app/components/budget-management/test/test.component.css

@@ -0,0 +1,194 @@
+.container_test {
+    width: 100%;
+    display: flex;
+    flex-direction: row;
+    height: calc(100% - 51px);
+}
+
+.options {
+    width: 256px;
+    margin-right: 8px;
+    height: 100%;
+    overflow: auto;
+}
+
+.calendar {
+    width: calc(100% - 264px);
+    height: 100%;
+    overflow: auto;
+}
+
+.content_calendar_option {
+    height: 60px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    justify-content: space-between;
+    border-bottom: rgb(218,220,224) 1px solid;
+}
+
+.calendar_config {
+    display: flex;
+    align-items: center;
+}
+    
+
+.container_calendar {
+    display: flex;
+    flex-direction: column;
+    border-left: rgb(218,220,224) 1px solid;
+    height: 100%;
+}
+
+.content_day {
+    display: flex;
+    flex-direction: row;
+    width: 100%; 
+}
+.content_week {
+    display: flex;
+    flex-direction: row;
+    width: 100%;
+    border-bottom: rgb(218,220,224) 1px solid;
+}
+
+.item_week {
+    width: calc(100% / 7);
+    border-right: rgb(218,220,224) 1px solid;
+    text-align: center;
+    font-size: 11px;
+    text-transform: uppercase;
+    color: #70757A;
+}
+
+.item_date {
+    display: flex;
+    flex-direction: column;
+    width: calc(100% / 7);
+    border-right: rgb(218,220,224) 1px solid;
+    cursor: pointer;
+}
+
+.item_day{
+    width: 100%;
+    text-align: center;
+    padding: 5px 0;
+    font-size: 12px;
+    color: rgb(60,64,67);
+}
+
+.item_day-current_date {
+    width: 100%;
+    text-align: center;
+    padding: 5px 0;
+    font-size: 12px;
+    background-color: rgb(26,115,232);;
+    color: #FFFFFF;
+}
+
+.date_selected {
+    color: rgb(60,64,67);
+    font-size: 22px;
+    font-weight: 400;
+    letter-spacing: 0;
+    line-height: 28px;
+    white-space: nowrap;
+    margin-left: 8px;
+}
+
+.container_time {
+    width: 100%;
+    display: flex;
+    height: calc(100% - 78px);
+    overflow: auto;
+}
+
+.config_date {
+    color: rgb(60,64,67);
+    font-size: 16px;
+    font-weight: 400;
+    letter-spacing: 0;
+    line-height: 28px;
+    white-space: nowrap;
+    margin-left: 8px;
+    padding: 8px 0;
+}
+
+.content_times {
+    width: 50px;
+    text-align: end;
+}
+.item_time {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    height: 48px;
+    border-bottom: rgb(218,220,224) 1px solid;
+    font-size: 10px;
+    color: #70757A;
+}
+
+.content_data_time {
+    width: calc(100% - 50px);
+}
+
+.number_day {
+    font-size: 11px;
+    text-transform: uppercase;
+    color: #70757A;
+    letter-spacing: .8px;
+    line-height: 32px;
+    text-align: center;
+}
+
+.number_day-current_date {
+    font-size: 11px;
+    text-transform: uppercase;
+    color: rgb(26,115,232);
+    letter-spacing: .8px;
+    line-height: 32px;
+    text-align: center;
+}
+
+.number_date {
+    font-size: 26px;
+    letter-spacing: -2.6px;
+    line-height: 46px;
+    color: rgb(60,64,67);
+    text-align: center;
+}
+.number_date-current_date {
+    font-size: 26px;
+    letter-spacing: -2.6px;
+    line-height: 46px;
+    color: #FFFFFF;
+    font-weight: 500;
+    text-align: center;
+    display: flex;
+    justify-content: center;
+}
+.number_date-current_date div {
+    background-color: rgb(26,115,232);
+    width: 45px;
+    border-radius: 50px;
+}
+
+.item_date_week {
+    width: 50px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    margin-left: 50px;
+}
+
+.content_week_data {
+    display: flex;
+    flex-direction: row;
+    width: calc(100% - 50px);
+    margin-left: 50px;
+}
+
+.item_week_data {
+    width: calc(100% / 7);
+}

+ 107 - 63
sistema-mantenimiento-front/src/app/components/budget-management/test/test.component.html

@@ -5,78 +5,122 @@
             <nav class="override-nav">
                 <mat-card-title class="mat-card-title centre">Calendario</mat-card-title>
             </nav>
-            <div style="
-                width: 100%;
-                display: flex;
-                flex-direction: row;
-                height: 100%;
-            ">
-                <div style="
-                    width: 300px;
-                    background-color: red;
-                    height: 100%;
-                
-                ">
-                    
+
+            <div class="content_calendar_option">
+                <div class="calendar_config">
+                    <button mat-stroked-button class="ml-8" (click)="returnToday()">Hoy</button>
+
+                    <button mat-icon-button class="ml-4" (click)="previous()">
+                        <mat-icon>chevron_left</mat-icon>
+                    </button>
+                    <button mat-icon-button class="ml-2" (click)="next()">
+                        <mat-icon>chevron_right</mat-icon>
+                    </button>
+    
+                    <div class="date_selected"> 
+                        @if (typeCalendar === 'Día') {
+                            {{ resourcesService.weekDay[getDateSelected.getDay()].week }} {{ getDateSelected.getDate() }} de
+                        }
+                        {{ resourcesService.arrMonthLabel[getDateSelected.getMonth()] }} de {{ getDateSelected.getFullYear() }}
+                    </div>
+    
+                </div>
+                <div>
+                    <button mat-stroked-button class="mr-8" [matMenuTriggerFor]="menu">
+                        {{ typeCalendar }}
+                        <mat-icon>arrow_drop_down</mat-icon>
+                    </button>
+                    <mat-menu #menu="matMenu">
+                        <button mat-menu-item (click)="configTypeCalendar('Día')">
+                            <span>Día</span>
+                        </button>
+                        <button mat-menu-item (click)="configTypeCalendar('Semana')">
+                            <span>Semana</span>
+                        </button>
+                        <button mat-menu-item (click)="configTypeCalendar('Mes')">
+                            <span>Mes</span>
+                        </button>
+                    </mat-menu>
+                </div>
+            </div>
+            <div class="container_test">
+                <div class="options">
+                    <mat-calendar></mat-calendar>
                 </div>
-                <div style="
-                    width: calc(100% - 300px);
-                    height: 100%;
-                
-                ">
-                    <div style="
-                        width: 700px;
-                        display: flex;
-                        flex-direction: row;
-                        border: 1px solid grey;
-                    ">
-                        @for (week of arrWeek; track week) {
-                            <div style="
-                                display: flex;
-                                flex-direction: row;
-                            ">
-                                <div style="
-                                    display: flex;
-                                    flex-direction: column;
-                                    width: 100px;
-                                    height: 100px;
-                                    border: 1px solid grey;
-                                ">
-                                    {{ week }}
+                <div class="calendar">
+                    @switch (typeCalendar) {
+                        @case ("Día") {
+                            <div class="item_date_week">
+                                <div [class]="getDateSelected.getTime() === currentDate.getTime() ? 'number_day-current_date' : 'number_day'">
+                                    {{ resourcesService.weekDay[getDateSelected.getDay()].acronym }}
+                                </div>
+                                <div [class]="getDateSelected.getTime() === currentDate.getTime() ? 'number_date-current_date' : 'number_date'">
+                                    <div>{{ getDateSelected.getDate() }}</div>
+                                </div>
+                            </div>
+                            <div class="container_time">
+                                <div class="content_times">
+                                    @for (time of arrTimes; track time) {
+                                        <div class="item_time">{{ time }}</div>
+                                    }
+                                </div>
+                                <div class="content_data_time">
+                                    @for (time of arrTimes; track time) {
+                                        <div class="item_time"></div>
+                                    }
                                 </div>
                             </div>
                         }
-                    </div>
-                    
-                    <div style="
-                        width: 700px;
-                        display: flex;
-                        flex-direction: column;
-                        border: 1px solid grey;
-                    ">
-                        
-                        @for (calendarMonth of arrCalendarMonth; track calendarMonth) {
-                            <div style="
-                                display: flex;
-                                flex-direction: row;
-                            ">
-                                @for (date of calendarMonth; track date) {
-                                    <div style="
-                                        display: flex;
-                                        flex-direction: column;
-                                        width: 100px;
-                                        height: 100px;
-                                        border: 1px solid grey;
-                                    ">
-                                        <div style="padding: 5px;"> {{ date.getDate() }} </div>
-                                        <div>
-
+                        @case ("Semana") {
+                            <div class="content_week_data">
+                                @for (week of arrWeek; track week) {
+                                    <div class="item_week_data">
+                                        <div [class]="week.getTime() === currentDate.getTime() ? 'number_day-current_date' : 'number_day'">
+                                            {{ resourcesService.weekDay[week.getDay()].acronym }}
+                                        </div>
+                                        <div [class]="week.getTime() === currentDate.getTime() ? 'number_date-current_date' : 'number_date'">
+                                            <div>{{ week.getDate() }}</div>
                                         </div>
                                     </div>
                                 }
                             </div>
+                            <div class="container_time">
+                                <div class="content_times">
+                                    @for (time of arrTimes; track time) {
+                                        <div class="item_time">{{ time }}</div>
+                                    }
+                                </div>
+                                <div class="content_data_time">
+                                    @for (time of arrTimes; track time) {
+                                        <div class="item_time"></div>
+                                    }
+                                </div>
+                            </div>
                         }
-                    </div>
+                        @case ("Mes") {
+                            <div class="container_calendar">
+                                <div class="content_day">
+                                    @for (week of resourcesService.weekDay; track week) {
+                                        <div class="item_week"> {{ week.acronym }} </div>
+                                    }
+                                </div>
+                                @for (calendarMonth of arrCalendarMonth; track calendarMonth) {
+                                    <div class="content_week" [style.height]="sanitizer.bypassSecurityTrustStyle('calc(100% / '+arrCalendarMonth.length+')')">
+                                        @for (date of calendarMonth; track date) {
+                                            <div class="item_date" >
+                                                <div 
+                                                [class]="date.getTime() === currentDate.getTime() ? 'item_day-current_date' : 'item_day'"
+                                                class="item_day"> {{ date.getDate() }} </div>
+                                                <div>
+        
+                                                </div>
+                                            </div>
+                                        }
+                                    </div>
+                                }
+                            </div>
+                        }
+                    }
                 </div>
             </div>
         </section>

+ 125 - 35
sistema-mantenimiento-front/src/app/components/budget-management/test/test.component.ts

@@ -1,4 +1,6 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, HostListener, OnInit } from '@angular/core';
+import { ResourcesService } from 'src/app/services/resources/resources.service';
+import { DomSanitizer } from '@angular/platform-browser';
 
 @Component({
   selector: 'app-test',
@@ -7,63 +9,132 @@ import { Component, OnInit } from '@angular/core';
 })
 export class TestComponent implements OnInit {
 
-  public getMonthSelected: number;
-  public getYearSelected: number;
+  public getDateSelected: Date;
+  public currentDate: Date;
   public arrCalendarMonth: any[];
-  public arrWeek: string[];
-  constructor() {
-    this.getMonthSelected = new Date().getMonth();
-    this.getYearSelected = new Date().getFullYear();
-
+  public typeCalendar: 'Día' | 'Semana' | 'Mes';
+  public arrTimes: string[];
+  public arrWeek: Date[];
+  constructor(
+    public resourcesService: ResourcesService,
+    public sanitizer: DomSanitizer,
+  ) {
+    this.getDateSelected = new Date();
+    this.currentDate = new Date();
     this.arrCalendarMonth = [];
-    this.arrWeek = [
-      'Domingo',
-      'Lunes',
-      'Martes',
-      'Miercoles',
-      'Jueves',
-      'Viernes',
-      'Sábado',
-    ]
+    this.arrTimes = [];
+    this.arrWeek = [];
+    this.typeCalendar = 'Semana';
+    this._generateTimes();
+    
   }
   ngOnInit() {
-    this.generateCalendar();
+    this.configTypeCalendar('Semana');
+  }
+
+  private _generateTimes() {
+    this.arrTimes = [ 'GMT-06' ];
+    let periodicidy: string = 'AM';
+    for (let hour = 1; hour < 13; hour++) {
+      this.arrTimes.push(`${hour} ${periodicidy}`)
+      if (periodicidy === 'AM' && hour === 12) {
+        hour = 1;
+        periodicidy = 'PM';
+      }
+    }
+    this.arrTimes.pop();
   }
 
-  public generateCalendar() {
-    const YEAR_SLT: number = this.getYearSelected;
-    const MONTH_SLT: number = this.getMonthSelected;
+  public configTypeCalendar(type: 'Día' | 'Semana' | 'Mes') {
+    this.typeCalendar = type;
+    switch (type) {
+      case 'Día':
+        break;
+      case 'Semana':
+        this._generateWeek();
+        break;
+      case 'Mes':
+        this._generateCalendar();
+        break;
+    }
+  }
+
+  public returnToday() {
+    this.getDateSelected = new Date();
+    switch (this.typeCalendar) {
+      case 'Día':
+        break;
+      case 'Semana':
+        this._generateWeek();
+        break;
+      case 'Mes':
+        this._generateCalendar();
+        break;
+    }
+  }
+  public previous() {
+    switch (this.typeCalendar) {
+      case 'Día':
+        this.getDateSelected.setDate(this.getDateSelected.getDate() - 1);
+        break;
+      case 'Semana':
+        this.getDateSelected.setDate(this.getDateSelected.getDate() - 7);
+        this._generateWeek();
+        break;
+      case 'Mes':
+        this.getDateSelected.setMonth(this.getDateSelected.getMonth() - 1);
+        this._generateCalendar();
+        break;
+    }
+  }
+  public next() {
+    switch (this.typeCalendar) {
+      case 'Día':
+        this.getDateSelected.setDate(this.getDateSelected.getDate() + 1);
+        break;
+      case 'Semana':
+        this.getDateSelected.setDate(this.getDateSelected.getDate() + 7);
+        this._generateWeek();
+        break;
+      case 'Mes':
+        this.getDateSelected.setMonth(this.getDateSelected.getMonth() + 1);
+        this._generateCalendar();
+        break;
+    }
+  }
 
-    let firstDateSelected: Date = new Date(YEAR_SLT, MONTH_SLT, 1);
-    let lastDateSelected: Date = new Date(YEAR_SLT, MONTH_SLT+1, 0);
+  private _generateCalendar() {
+    const YEAR_SLT: number = this.getDateSelected.getFullYear();
+    const MONTH_SLT: number = this.getDateSelected.getMonth();
 
+    const FIRST_DATE: Date = new Date(YEAR_SLT, MONTH_SLT, 1);
+    const END_DATE: Date = new Date(YEAR_SLT, MONTH_SLT+1, 0);
 
     let arrStartCalendar = [];
     let arrEndCalendar = [];
     for (let day = 0; day < 7; day++) {
-      if (day < firstDateSelected.getDay()) {
-        let diffDay = firstDateSelected.getDay() - day;
-        let previuosDate = new Date(firstDateSelected);
-        previuosDate.setDate(firstDateSelected.getDate() - diffDay);
+      if (day < FIRST_DATE.getDay()) {
+        let diffDay = FIRST_DATE.getDay() - day;
+        let previuosDate = new Date(FIRST_DATE);
+        previuosDate.setDate(FIRST_DATE.getDate() - diffDay);
         arrStartCalendar.push(previuosDate);
-      } 
+      }
 
-      if (day > lastDateSelected.getDay()) {
-        let diffDay = day - lastDateSelected.getDay();
-        let nextDate = new Date(lastDateSelected);
-        nextDate.setDate(lastDateSelected.getDate() + diffDay);
+      if (day > END_DATE.getDay()) {
+        let diffDay = day - END_DATE.getDay();
+        let nextDate = new Date(END_DATE);
+        nextDate.setDate(END_DATE.getDate() + diffDay);
         arrEndCalendar.push(nextDate);
       }
     }
 
-
     this.arrCalendarMonth = [];
     let numWeeks = 0;
     this.arrCalendarMonth[numWeeks] = [];
-    for (let date = firstDateSelected.getDate(); date <= lastDateSelected.getDate(); date++) {
+    for (let date = FIRST_DATE.getDate(); date <= END_DATE.getDate(); date++) {
       let DATE_MONTH: Date = new Date(YEAR_SLT, MONTH_SLT, date);
       this.arrCalendarMonth[numWeeks].push(DATE_MONTH)
-      if (DATE_MONTH.getDay() === 6) {
+      if (DATE_MONTH.getDay() === 6 && date < END_DATE.getDate() ) {
         numWeeks++;
         this.arrCalendarMonth[numWeeks] = [];
       }
@@ -79,5 +150,24 @@ export class TestComponent implements OnInit {
       }
       this.arrCalendarMonth[numWeeks] = element;
     }
+    
+  }
+  private _generateWeek() {
+    this.arrWeek = [];
+    for (let day = 0; day < 7; day++) {
+      if (day < this.getDateSelected.getDay()) {
+        let diff = this.getDateSelected.getDay() - day;
+        let previuosDate = new Date(this.getDateSelected);
+        previuosDate.setDate(this.getDateSelected.getDate() - diff);
+        this.arrWeek.push(previuosDate);
+      } else if (day === this.getDateSelected.getDay()) {
+        this.arrWeek.push(this.getDateSelected);
+      } else {
+        let diff = day - this.getDateSelected.getDay();
+        let nextDate = new Date(this.getDateSelected);
+        nextDate.setDate(this.getDateSelected.getDate() + diff);
+        this.arrWeek.push(nextDate);
+      }
+    }
   }
 }

+ 31 - 0
sistema-mantenimiento-front/src/app/services/resources/resources.service.ts

@@ -17,6 +17,7 @@ export class ResourcesService {
 
   public arrMonth: Array<string>;
   public arrMonthLabel: Array<string>;
+  public weekDay: Array<any>;
   public weekDays: Array<string>;
   constructor(
     private _encService: EncService,
@@ -53,6 +54,36 @@ export class ResourcesService {
       'Diciembre'
     ];
 
+    this.weekDay = [
+      {
+        week: 'Domingo',
+        acronym: 'Dom'
+      }, 
+      {
+        week: 'Lunes',
+        acronym: 'Lun'
+      }, 
+      {
+        week: 'Martes',
+        acronym: 'Mar'
+      }, 
+      {
+        week: 'Miércoles',
+        acronym: 'Mié'
+      }, 
+      {
+        week: 'Jueves',
+        acronym: 'Jue'
+      }, 
+      {
+        week: 'Viernes',
+        acronym: 'Vie'
+      }, 
+      {
+        week:  'Sábado',
+        acronym: 'Sáb'
+      }
+    ];
     this.weekDays = ['Domingos', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábados'];
   }
 

+ 1 - 0
sistema-mantenimiento-front/src/styles.css

@@ -459,6 +459,7 @@ body {
 .p-0 {padding: 0 !important;}
 .p-2 {padding: 2px !important;}
 .p-4 {padding: 4px !important;}
+.p-5 {padding: 5px !important;}
 .p-8 {padding: 8px !important;}
 .p-16 {padding: 16px !important;}
 .p-20 {padding: 20px !important;}