diff --git a/samples/react-calendar/package.json b/samples/react-calendar/package.json index e49d65b14..ad8cec1b8 100644 --- a/samples/react-calendar/package.json +++ b/samples/react-calendar/package.json @@ -1,6 +1,6 @@ { "name": "react-calendar", - "version": "0.0.1", + "version": "1.0.0", "private": true, "engines": { "node": ">=0.10.0" diff --git a/samples/react-calendar/src/controls/Event/event.tsx b/samples/react-calendar/src/controls/Event/event.tsx index a188b5059..8984ba329 100644 --- a/samples/react-calendar/src/controls/Event/event.tsx +++ b/samples/react-calendar/src/controls/Event/event.tsx @@ -167,7 +167,6 @@ export class Event extends React.Component { const end = moment(endDateTime, 'YYYY/MM/DD HH:mm').toLocaleString(); eventData.end = new Date(end); - debugger; // get Geolocation eventData.geolocation = { Latitude: this.latitude, Longitude: this.longitude }; diff --git a/samples/react-calendar/src/services/spservices.ts b/samples/react-calendar/src/services/spservices.ts index 9f1c11c76..dd024aa1d 100644 --- a/samples/react-calendar/src/services/spservices.ts +++ b/samples/react-calendar/src/services/spservices.ts @@ -13,7 +13,7 @@ import * as moment from 'moment'; import { SiteUser } from "@pnp/sp/src/siteusers"; import { IUserPermissions } from './IUserPermissions'; import { dateAdd } from "@pnp/common"; - +import { escape } from '@microsoft/sp-lodash-subset'; const ADMIN_ROLETEMPLATE_ID = "62e90394-69f5-4237-9190-012177145e10"; // Global Admin TemplateRoleId // Class Services @@ -60,7 +60,12 @@ export default class spservices { siteTimeZoneDaylightBias = siteRegionalSettings.Information.DaylightBias; // Formula to calculate the number of hours need to get UTC Date. - numberHours = (siteTimeZoneBias / 60) + (siteTimeZoneDaylightBias / 60) - currentDateTimeOffSet; + // numberHours = (siteTimeZoneBias / 60) + (siteTimeZoneDaylightBias / 60) - currentDateTimeOffSet; + if ( siteTimeZoneBias >= 0 ){ + numberHours = ((siteTimeZoneBias / 60) - currentDateTimeOffSet) + siteTimeZoneDaylightBias/60 ; + }else { + numberHours = ((siteTimeZoneBias / 60) - currentDateTimeOffSet) ; + } } catch (error) { return Promise.reject(error); @@ -235,11 +240,13 @@ export default class spservices { let userPermissions: IUserPermissions = undefined; try { const web = new Web(siteUrl); - hasPermissionAdd = await web.lists.getById(listId).currentUserHasPermissions(PermissionKind.AddListItems); - hasPermissionEdit = await web.lists.getById(listId).currentUserHasPermissions(PermissionKind.EditListItems); - hasPermissionDelete = await web.lists.getById(listId).currentUserHasPermissions(PermissionKind.DeleteListItems); - hasPermissionView = await web.lists.getById(listId).currentUserHasPermissions(PermissionKind.ViewListItems); - userPermissions = { hasPermissionAdd: hasPermissionAdd, hasPermissionEdit: hasPermissionEdit, hasPermissionDelete: hasPermissionDelete, hasPermissionView: hasPermissionView }; + const userEffectivePermissions = await web.lists.getById(listId).effectiveBasePermissions.get(); + // chaeck user permissions + hasPermissionAdd = sp.web.lists.getById(listId).hasPermissions(userEffectivePermissions, PermissionKind.AddListItems); + hasPermissionEdit =sp.web.lists.getById(listId).hasPermissions(userEffectivePermissions, PermissionKind.EditListItems); + hasPermissionDelete =sp.web.lists.getById(listId).hasPermissions(userEffectivePermissions, PermissionKind.DeleteListItems); + hasPermissionView = sp.web.lists.getById(listId).hasPermissions(userEffectivePermissions, PermissionKind.ViewListItems); + userPermissions = { hasPermissionAdd: hasPermissionAdd, hasPermissionEdit: hasPermissionEdit, hasPermissionDelete: hasPermissionDelete, hasPermissionView: hasPermissionView }; } catch (error) { return Promise.reject(error); } @@ -375,46 +382,46 @@ export default class spservices { } ); - if (results && results.Row.length > 0) { - for (const event of results.Row) { - const initialsArray: string[] = event.Author[0].title.split(' '); - const initials: string = initialsArray[0].charAt(0) + initialsArray[initialsArray.length - 1].charAt(0); - const userPictureUrl = await this.getUserProfilePictureUrl(`i:0#.f|membership|${event.Author[0].email}`); - const attendees: number[] = []; - const first: number = event.Geolocation.indexOf('(') + 1; - const last: number = event.Geolocation.indexOf(')'); - const geo = event.Geolocation.substring(first, last); - const geolocation = geo.split(' '); - const CategoryColorValue: any[] = categoryColor.filter((value) => { - return value.category == event.Category; - }); - for (const attendee of event.ParticipantsPicker) { - attendees.push(parseInt(attendee.id)); - } - - events.push({ - id: event.ID, - title: event.Title, - Description: event.Description, - // start: moment(event.EventDate).utc().toDate().setUTCMinutes(this.siteTimeZoneOffSet), - start: new Date(moment(event.EventDate).subtract(siteTimeZoneHoursToUTC, 'hour').toISOString()), - // end: new Date(moment(event.EndDate).toLocaleString()), - end: new Date(moment(event.EndDate).subtract(siteTimeZoneHoursToUTC, 'hour').toISOString()), - location: event.Location, - ownerEmail: event.Author[0].email, - ownerPhoto: userPictureUrl ? - `https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=${event.Author[0].email}&UA=0&size=HR96x96` : '', - ownerInitial: initials, - // color: await this.colorGenerate(), - color: CategoryColorValue.length > 0 ? CategoryColorValue[0].color : await this.colorGenerate, - ownerName: event.Author[0].title, - attendes: attendees, - allDayEvent: false, - geolocation: { Longitude: parseFloat(geolocation[0]), Latitude: parseFloat(geolocation[1]) }, - Category: event.Category - }); - } + if (results && results.Row.length > 0) { + for (const event of results.Row) { + const initialsArray: string[] = event.Author[0].title.split(' '); + const initials: string = initialsArray[0].charAt(0) + initialsArray[initialsArray.length - 1].charAt(0); + const userPictureUrl = await this.getUserProfilePictureUrl(`i:0#.f|membership|${event.Author[0].email}`); + const attendees: number[] = []; + const first: number = event.Geolocation.indexOf('(') + 1; + const last: number = event.Geolocation.indexOf(')'); + const geo = event.Geolocation.substring(first, last); + const geolocation = geo.split(' '); + const CategoryColorValue: any[] = categoryColor.filter((value) => { + return value.category == event.Category; + }); + for (const attendee of event.ParticipantsPicker) { + attendees.push(parseInt(attendee.id)); } + + events.push({ + id: event.ID, + title: await this.deCodeHtmlEntities(event.Title), + Description: event.Description, + // start: moment(event.EventDate).utc().toDate().setUTCMinutes(this.siteTimeZoneOffSet), + start: new Date(moment(event.EventDate).subtract((siteTimeZoneHoursToUTC), 'hour').toISOString()), + // end: new Date(moment(event.EndDate).toLocaleString()), + end: new Date(moment(event.EndDate).subtract(siteTimeZoneHoursToUTC, 'hour').toISOString()), + location: event.Location, + ownerEmail: event.Author[0].email, + ownerPhoto: userPictureUrl ? + `https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=${event.Author[0].email}&UA=0&size=HR96x96` : '', + ownerInitial: initials, + // color: await this.colorGenerate(), + color: CategoryColorValue.length > 0 ? CategoryColorValue[0].color : await this.colorGenerate, + ownerName: event.Author[0].title, + attendes: attendees, + allDayEvent: false, + geolocation: { Longitude: parseFloat(geolocation[0]), Latitude: parseFloat(geolocation[1]) }, + Category: event.Category + }); + } + } // Return Data return events; } catch (error) { @@ -467,4 +474,525 @@ export default class spservices { return Promise.reject(error); } } + + public async enCodeHtmlEntities(string: string) { + + const HtmlEntitiesMap = { + "'": "'", + "<": "<", + ">": ">", + " ": " ", + "¡": "¡", + "¢": "¢", + "£": "£", + "¤": "¤", + "¥": "¥", + "¦": "¦", + "§": "§", + "¨": "¨", + "©": "©", + "ª": "ª", + "«": "«", + "¬": "¬", + "®": "®", + "¯": "¯", + "°": "°", + "±": "±", + "²": "²", + "³": "³", + "´": "´", + "µ": "µ", + "¶": "¶", + "·": "·", + "¸": "¸", + "¹": "¹", + "º": "º", + "»": "»", + "¼": "¼", + "½": "½", + "¾": "¾", + "¿": "¿", + "À": "À", + "Á": "Á", + "Â": "Â", + "Ã": "Ã", + "Ä": "Ä", + "Å": "Å", + "Æ": "Æ", + "Ç": "Ç", + "È": "È", + "É": "É", + "Ê": "Ê", + "Ë": "Ë", + "Ì": "Ì", + "Í": "Í", + "Î": "Î", + "Ï": "Ï", + "Ð": "Ð", + "Ñ": "Ñ", + "Ò": "Ò", + "Ó": "Ó", + "Ô": "Ô", + "Õ": "Õ", + "Ö": "Ö", + "×": "×", + "Ø": "Ø", + "Ù": "Ù", + "Ú": "Ú", + "Û": "Û", + "Ü": "Ü", + "Ý": "Ý", + "Þ": "Þ", + "ß": "ß", + "à": "à", + "á": "á", + "â": "â", + "ã": "ã", + "ä": "ä", + "å": "å", + "æ": "æ", + "ç": "ç", + "è": "è", + "é": "é", + "ê": "ê", + "ë": "ë", + "ì": "ì", + "í": "í", + "î": "î", + "ï": "ï", + "ð": "ð", + "ñ": "ñ", + "ò": "ò", + "ó": "ó", + "ô": "ô", + "õ": "õ", + "ö": "ö", + "÷": "÷", + "ø": "ø", + "ù": "ù", + "ú": "ú", + "û": "û", + "ü": "ü", + "ý": "ý", + "þ": "þ", + "ÿ": "ÿ", + "Œ": "Œ", + "œ": "œ", + "Š": "Š", + "š": "š", + "Ÿ": "Ÿ", + "ƒ": "ƒ", + "ˆ": "ˆ", + "˜": "˜", + "Α": "Α", + "Β": "Β", + "Γ": "Γ", + "Δ": "Δ", + "Ε": "Ε", + "Ζ": "Ζ", + "Η": "Η", + "Θ": "Θ", + "Ι": "Ι", + "Κ": "Κ", + "Λ": "Λ", + "Μ": "Μ", + "Ν": "Ν", + "Ξ": "Ξ", + "Ο": "Ο", + "Π": "Π", + "Ρ": "Ρ", + "Σ": "Σ", + "Τ": "Τ", + "Υ": "Υ", + "Φ": "Φ", + "Χ": "Χ", + "Ψ": "Ψ", + "Ω": "Ω", + "α": "α", + "β": "β", + "γ": "γ", + "δ": "δ", + "ε": "ε", + "ζ": "ζ", + "η": "η", + "θ": "θ", + "ι": "ι", + "κ": "κ", + "λ": "λ", + "μ": "μ", + "ν": "ν", + "ξ": "ξ", + "ο": "ο", + "π": "π", + "ρ": "ρ", + "ς": "ς", + "σ": "σ", + "τ": "τ", + "υ": "υ", + "φ": "φ", + "χ": "χ", + "ψ": "ψ", + "ω": "ω", + "ϑ": "ϑ", + "ϒ": "&Upsih;", + "ϖ": "ϖ", + "–": "–", + "—": "—", + "‘": "‘", + "’": "’", + "‚": "‚", + "“": "“", + "”": "”", + "„": "„", + "†": "†", + "‡": "‡", + "•": "•", + "…": "…", + "‰": "‰", + "′": "′", + "″": "″", + "‹": "‹", + "›": "›", + "‾": "‾", + "⁄": "⁄", + "€": "€", + "ℑ": "ℑ", + "℘": "℘", + "ℜ": "ℜ", + "™": "™", + "ℵ": "ℵ", + "←": "←", + "↑": "↑", + "→": "→", + "↓": "↓", + "↔": "↔", + "↵": "↵", + "⇐": "⇐", + "⇑": "&UArr;", + "⇒": "⇒", + "⇓": "⇓", + "⇔": "⇔", + "∀": "∀", + "∂": "∂", + "∃": "∃", + "∅": "∅", + "∇": "∇", + "∈": "∈", + "∉": "∉", + "∋": "∋", + "∏": "∏", + "∑": "∑", + "−": "−", + "∗": "∗", + "√": "√", + "∝": "∝", + "∞": "∞", + "∠": "∠", + "∧": "∧", + "∨": "∨", + "∩": "∩", + "∪": "∪", + "∫": "∫", + "∴": "∴", + "∼": "∼", + "≅": "≅", + "≈": "≈", + "≠": "≠", + "≡": "≡", + "≤": "≤", + "≥": "≥", + "⊂": "⊂", + "⊃": "⊃", + "⊄": "⊄", + "⊆": "⊆", + "⊇": "⊇", + "⊕": "⊕", + "⊗": "⊗", + "⊥": "⊥", + "⋅": "⋅", + "⌈": "⌈", + "⌉": "⌉", + "⌊": "⌊", + "⌋": "⌋", + "⟨": "⟨", + "⟩": "⟩", + "◊": "◊", + "♠": "♠", + "♣": "♣", + "♥": "♥", + "♦": "♦" + }; + + var entityMap = HtmlEntitiesMap; + string = string.replace(/&/g, '&'); + string = string.replace(/"/g, '"'); + for (var key in entityMap) { + var entity = entityMap[key]; + var regex = new RegExp(key, 'g'); + string = string.replace(regex, entity); + } + return string; + } + + public async deCodeHtmlEntities(string: string) { + + const HtmlEntitiesMap = { + "'": "'", + "<": "<", + ">": ">", + " ": " ", + "¡": "¡", + "¢": "¢", + "£": "£", + "¤": "¤", + "¥": "¥", + "¦": "¦", + "§": "§", + "¨": "¨", + "©": "©", + "ª": "ª", + "«": "«", + "¬": "¬", + "®": "®", + "¯": "¯", + "°": "°", + "±": "±", + "²": "²", + "³": "³", + "´": "´", + "µ": "µ", + "¶": "¶", + "·": "·", + "¸": "¸", + "¹": "¹", + "º": "º", + "»": "»", + "¼": "¼", + "½": "½", + "¾": "¾", + "¿": "¿", + "À": "À", + "Á": "Á", + "Â": "Â", + "Ã": "Ã", + "Ä": "Ä", + "Å": "Å", + "Æ": "Æ", + "Ç": "Ç", + "È": "È", + "É": "É", + "Ê": "Ê", + "Ë": "Ë", + "Ì": "Ì", + "Í": "Í", + "Î": "Î", + "Ï": "Ï", + "Ð": "Ð", + "Ñ": "Ñ", + "Ò": "Ò", + "Ó": "Ó", + "Ô": "Ô", + "Õ": "Õ", + "Ö": "Ö", + "×": "×", + "Ø": "Ø", + "Ù": "Ù", + "Ú": "Ú", + "Û": "Û", + "Ü": "Ü", + "Ý": "Ý", + "Þ": "Þ", + "ß": "ß", + "à": "à", + "á": "á", + "â": "â", + "ã": "ã", + "ä": "ä", + "å": "å", + "æ": "æ", + "ç": "ç", + "è": "è", + "é": "é", + "ê": "ê", + "ë": "ë", + "ì": "ì", + "í": "í", + "î": "î", + "ï": "ï", + "ð": "ð", + "ñ": "ñ", + "ò": "ò", + "ó": "ó", + "ô": "ô", + "õ": "õ", + "ö": "ö", + "÷": "÷", + "ø": "ø", + "ù": "ù", + "ú": "ú", + "û": "û", + "ü": "ü", + "ý": "ý", + "þ": "þ", + "ÿ": "ÿ", + "Œ": "Œ", + "œ": "œ", + "Š": "Š", + "š": "š", + "Ÿ": "Ÿ", + "ƒ": "ƒ", + "ˆ": "ˆ", + "˜": "˜", + "Α": "Α", + "Β": "Β", + "Γ": "Γ", + "Δ": "Δ", + "Ε": "Ε", + "Ζ": "Ζ", + "Η": "Η", + "Θ": "Θ", + "Ι": "Ι", + "Κ": "Κ", + "Λ": "Λ", + "Μ": "Μ", + "Ν": "Ν", + "Ξ": "Ξ", + "Ο": "Ο", + "Π": "Π", + "Ρ": "Ρ", + "Σ": "Σ", + "Τ": "Τ", + "Υ": "Υ", + "Φ": "Φ", + "Χ": "Χ", + "Ψ": "Ψ", + "Ω": "Ω", + "α": "α", + "β": "β", + "γ": "γ", + "δ": "δ", + "ε": "ε", + "ζ": "ζ", + "η": "η", + "θ": "θ", + "ι": "ι", + "κ": "κ", + "λ": "λ", + "μ": "μ", + "ν": "ν", + "ξ": "ξ", + "ο": "ο", + "π": "π", + "ρ": "ρ", + "ς": "ς", + "σ": "σ", + "τ": "τ", + "υ": "υ", + "φ": "φ", + "χ": "χ", + "ψ": "ψ", + "ω": "ω", + "ϑ": "ϑ", + "ϒ": "&Upsih;", + "ϖ": "ϖ", + "–": "–", + "—": "—", + "‘": "‘", + "’": "’", + "‚": "‚", + "“": "“", + "”": "”", + "„": "„", + "†": "†", + "‡": "‡", + "•": "•", + "…": "…", + "‰": "‰", + "′": "′", + "″": "″", + "‹": "‹", + "›": "›", + "‾": "‾", + "⁄": "⁄", + "€": "€", + "ℑ": "ℑ", + "℘": "℘", + "ℜ": "ℜ", + "™": "™", + "ℵ": "ℵ", + "←": "←", + "↑": "↑", + "→": "→", + "↓": "↓", + "↔": "↔", + "↵": "↵", + "⇐": "⇐", + "⇑": "&UArr;", + "⇒": "⇒", + "⇓": "⇓", + "⇔": "⇔", + "∀": "∀", + "∂": "∂", + "∃": "∃", + "∅": "∅", + "∇": "∇", + "∈": "∈", + "∉": "∉", + "∋": "∋", + "∏": "∏", + "∑": "∑", + "−": "−", + "∗": "∗", + "√": "√", + "∝": "∝", + "∞": "∞", + "∠": "∠", + "∧": "∧", + "∨": "∨", + "∩": "∩", + "∪": "∪", + "∫": "∫", + "∴": "∴", + "∼": "∼", + "≅": "≅", + "≈": "≈", + "≠": "≠", + "≡": "≡", + "≤": "≤", + "≥": "≥", + "⊂": "⊂", + "⊃": "⊃", + "⊄": "⊄", + "⊆": "⊆", + "⊇": "⊇", + "⊕": "⊕", + "⊗": "⊗", + "⊥": "⊥", + "⋅": "⋅", + "⌈": "⌈", + "⌉": "⌉", + "⌊": "⌊", + "⌋": "⌋", + "⟨": "⟨", + "⟩": "⟩", + "◊": "◊", + "♠": "♠", + "♣": "♣", + "♥": "♥", + "♦": "♦" + }; + + var entityMap = HtmlEntitiesMap; + for (var key in entityMap) { + var entity = entityMap[key]; + var regex = new RegExp(entity, 'g'); + string = string.replace(regex, key); + } + string = string.replace(/"/g, '"'); + string = string.replace(/&/g, '&'); + return string; + } + + + } diff --git a/samples/react-calendar/src/webparts/calendar/components/Calendar.module.scss b/samples/react-calendar/src/webparts/calendar/components/Calendar.module.scss index 2c4e81e52..854ae451b 100644 --- a/samples/react-calendar/src/webparts/calendar/components/Calendar.module.scss +++ b/samples/react-calendar/src/webparts/calendar/components/Calendar.module.scss @@ -38,10 +38,11 @@ border-style: 'solid'; border-width: 1.3px; border-color: #e6e6e6; - height: 40px; + height:auto; justify-content: 'center'; display: 'flex'; align-items: 'top'; + } .eventStyle{ @@ -55,12 +56,15 @@ } .DocumentCardTitle { - font-weight: 'bold'; + font-weight: $ms-font-weight-semibold; height: '100%'; + text-overflow: ellipsis; + display: 'flex'; + justify-content: 'center'; } .DocumentCardTitleTime{ - + padding-top: 10px; justify-content: 'center'; display: 'flex'; align-items: 'top'; diff --git a/samples/react-calendar/src/webparts/calendar/components/Calendar.tsx b/samples/react-calendar/src/webparts/calendar/components/Calendar.tsx index 6ac74b476..9721aaee5 100644 --- a/samples/react-calendar/src/webparts/calendar/components/Calendar.tsx +++ b/samples/react-calendar/src/webparts/calendar/components/Calendar.tsx @@ -193,7 +193,7 @@ export default class Calendar extends React.Component
- +
{ @@ -202,7 +202,6 @@ export default class Calendar extends React.Component{moment(event.start).format('dddd')} } - {moment(event.start).format('HH:mm')}H - {moment(event.end).format('HH:mm')}H \ No newline at end of file +