Skip to content

Commit

Permalink
Merge pull request #164 from intri-in/development
Browse files Browse the repository at this point in the history
v0.5.1
  • Loading branch information
intri-in committed Apr 9, 2024
2 parents ce15c81 + ac040b8 commit 7f14824
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 33 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.5.1
- Fixed bug with recurring task.
- Editing the task will now only set done status for the current recurrence id.
- Add task component's input is now cleared with the task editor box opens
- Fixed #159
- Problem arose because of the type of any event created in other clients was not being recognised.

v0.5.0
- Version Bump to 0.5.0
- Added Jotai for state management
Expand Down
9 changes: 6 additions & 3 deletions COMMITMESSAGE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Added move to calendar option to Task Editor.
- Before setting a default calendar in Event and Taskeditors, added a check to make sure it is a valid id.
- UI Improvement to Home Page
- Fixed bug with recurring task.
- Editing the task will now only set done status for the current recurrence id.
- Add task component's input is now cleared with the task editor box opens
- Fixed #159
- Problem arose because of the type of any event created in other clients was not being recognised.
- Version bump to 0.5.1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manage-my-damn-life-nextjs",
"version": "0.5.0",
"version": "0.5.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/AddTask/AddTaskFunctional.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ export function AddTaskFunctional(props) {
const openTaskEditor = () =>{

let dataToPush = {...data}

if(calDavObject && calDavObject.calendars_id){
dataToPush.calendar_id= calDavObject.calendars_id
}
setTaskInputAtom(dataToPush)
setNewTaskSummary("")

showTaskEditor(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ export const CalendarViewWithStateManagement = ({ calendarAR }: { calendarAR: nu
if (event.deleted == "1" || event.deleted == "TRUE") {
continue
}
// console.log(event.type, event.calendar_events_id)
if (event.type != "VTODO" && event.type != "VTIMEZONE") {
const data = getParsedEvent(allEvents[i].events[j].data)
// console.log("Parsed Event", data.summary, event.calendar_id, data)
if (varNotEmpty(data) == false) {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Datepicker } from "@/components/common/Datepicker/Datepicker"
import { CalendarPicker } from "@/components/common/Calendarpicker"
import { PRIMARY_COLOUR } from "@/config/style"
import { moveEventModalInput, showMoveEventModal } from "stateStore/MoveEventStore"
import next from "next/types"

const i18next = getI18nObject()
export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailog, onServerResponse, closeEditor }: { input: TaskEditorInputType, onChange: Function, showDeleteDailog: Function, onServerResponse: Function, closeEditor: Function }) => {
Expand Down Expand Up @@ -75,6 +76,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
const [category, setCategory] = useState<string[]>([])
const [calendarDDLDisabled, setCalendarDDLDisabled] = useState(false)
const [showMoveEventOption, setShowMoveEventOption]= useState(false)
const [recurrenceObj, setRecurrenceObj] = useState<any>({})
const changeDoneStatus = (isDone: boolean) => {
if (isDone) {
const completedDate = getISO8601Date(moment().toISOString())
Expand Down Expand Up @@ -131,7 +133,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
// console.log("this.state.calendar_id at DDL", this.state.calendar_id)
}

const checkInputForNewTask = async () => {
const checkInputForNewTask = async (isRecurring?: boolean) => {
if (input) {
if (!input.id) {
//Task is New.
Expand Down Expand Up @@ -189,7 +191,10 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
//Process done info .
if (input.taskDone) {
setTaskDone(true)
changeDoneStatus(true)
// console.log("isRepeatingTask", isRepeatingTask)
if(!isRecurring){
changeDoneStatus(true)
}

}

Expand Down Expand Up @@ -253,7 +258,11 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
}
//Check and set repeating task parameters.
setRrule(rruleToObject(parsedData["rrule"]))
const isRecurring = parsedData["rrule"] ? true : false
if (parsedData["rrule"]) {
const parsedRecurrenceObj = new RecurrenceHelper(parsedData)
// console.log(parsedRecurrenceObj)
setRecurrenceObj(parsedRecurrenceObj)
setIsRepeatingTask(true)
}
if (parsedData["priority"]) setPriority(parsedData["priority"])
Expand All @@ -266,7 +275,7 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
}
// console.log(parsedData)
// getLabels(parsedData["category"])
checkInputForNewTask()
checkInputForNewTask(isRecurring)
}
}

Expand Down Expand Up @@ -294,17 +303,43 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
* Probably to set done for the new recurrenceid.
* {TODO}: Figure it out
*/
let recurrenceObj = new RecurrenceHelper(parsedDataFromDexie)
recurrences = _.cloneDeep(recurrenceObj.newRecurrence)
if (Object.keys(recurrenceObj.newObj).length > 0 && recurrences) {
const nextupKey = recurrenceObj.getNextUpKey()
recurrences[nextupKey] = recurrenceObj.newObj[nextupKey]
try{

if (Object.keys(recurrenceObj.newObj).length > 0 && recurrences) {
const nextupKey = recurrenceObj.getNextUpKey()
if(!nextupKey){
toast.error("NextUpKey is empty!")
return
}
recurrences[nextupKey] = recurrenceObj.newObj[nextupKey]
const completedDate = getISO8601Date(moment().toISOString())
/**
* If done, set next repeating instance as completed.
*/
if(taskDone){
recurrences[nextupKey]["completed"] = completedDate
recurrences[nextupKey]["completion"] = "100"
recurrences[nextupKey]["status"] = "COMPLETED"

}else{
recurrences[nextupKey]["completed"] = ""
recurrences[nextupKey]["completion"] = ""
recurrences[nextupKey]["status"] = ""
}


if (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) == false || (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) && recurrences[nextupKey]["recurrenceid"] == "")) {
recurrences[nextupKey]["recurrenceid"] = getISO8601Date(nextupKey)
}

if (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) == false || (varNotEmpty(recurrences[nextupKey]["recurrenceid"]) && recurrences[nextupKey]["recurrenceid"] == "")) {
recurrences[nextupKey]["recurrenceid"] = getISO8601Date(nextupKey)
}

}
}catch(e){
console.warn("Recurrence problem: "+summary, e, )
}


}

if (!summary) {
Expand All @@ -316,12 +351,9 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
//dueDateToSave = fixDueDate(dueDate)
dueDateToSave = moment(moment(dueDate).format(dateFullFormat)).toISOString()
}
console.log("due date to save", dueDate, taskStart)
// console.log("due date to save", dueDate, taskStart)
const valid = await checkifValid()
if (valid) {
if (taskDone) {

}
setSubmitting(true)
const todoData = { due: dueDate, start: taskStart, summary: summary, created: parsedDataFromDexie.created, completion: completion, completed: completed, status: status, uid: uid, categories: category, priority: priority, relatedto: relatedto, lastmodified: "", dtstamp: parsedDataFromDexie.dtstamp, description: description, rrule: rrule, recurrences: recurrences }
const finalTodoData = await generateNewTaskObject(todoData, parsedDataFromDexie, unParsedData)
Expand Down Expand Up @@ -438,6 +470,11 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo

}
}

if(isRepeatingTask){
//Check if the task can even be saved.

}
return true
}

Expand Down Expand Up @@ -517,7 +554,9 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo

const taskDoneChanged = (e) => {
setTaskDone(e.target.checked)
changeDoneStatus(e.target.checked)
if(!isRepeatingTask){
changeDoneStatus(e.target.checked)
}

}
const statusValueChanged = (e) => {
Expand Down Expand Up @@ -594,9 +633,8 @@ export const TaskEditorWithStateManagement = ({ input, onChange, showDeleteDailo
let repeatInfoMessage: JSX.Element = <></>
let dueDateFixed = ""
if (isRepeatingTask) {
const repeatingInfo = new RecurrenceHelper(parsedDataFromDexie)
dueDateFixed = moment(repeatingInfo.getNextDueDate()).format(dateFullFormat)
repeatInfoMessage = (<Alert variant="warning">{i18next.t("REPEAT_TASK_MESSAGE") + moment(new Date(repeatingInfo.getNextDueDate())).format(dateFormat)}</Alert>)
dueDateFixed = moment(recurrenceObj.getNextDueDate()).format(dateFullFormat)
repeatInfoMessage = (<Alert variant="warning">{i18next.t("REPEAT_TASK_MESSAGE") + moment(recurrenceObj.getNextDueDate()).format(dateFormat)}</Alert>)
}


Expand Down
2 changes: 1 addition & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const VERSION_NUMBER = "0.5.0"
export const VERSION_NUMBER = "0.5.1"
/*
* SYSTEM_DEFAULT_LABEL_PREFIX: Default prefix applied to all system generated labels like
* "My Day"
Expand Down
10 changes: 6 additions & 4 deletions src/helpers/api/cal/caldav.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ export function checkifObjectisVTODO(data)
try{
const parsedData = ical.parseICS(data);
for (let k in parsedData) {
// console.log("parse Success")
return parsedData[k].type
// console.log("parse Success",k, parsedData[k])
if(parsedData[k].type=="VTODO" || parsedData[k].type=="VEVENT") {
return parsedData[k].type
}
}

}catch(e){
Expand All @@ -191,9 +193,9 @@ export function checkifObjectisVTODO(data)
if(type=="")
{
const parsedData = parseICSWithICALJS(data, "VTODO");
// console.log("parse Success", parsedData)
console.log("parse Success", parsedData)

if(varNotEmpty(parsedData) && parsedData!={})
if(varNotEmpty(parsedData) && ("summary" in parsedData) && parsedData!={})
{
return "VTODO"
}else{
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/frontend/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ export function returnEventType(data)
try{
const parsedData = ical.parseICS(data);
for (let k in parsedData) {
return parsedData[k].type

if(parsedData[k].type=="VTODO" || parsedData[k].type=="VEVENT") {
return parsedData[k].type
}
}

}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/frontend/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export function getParsedEvent(dataInput)
{
for(const key in data)
{
// console.log("data[key]", data[key])
if(data[key].type=="VEVENT")
{
return data[key]
Expand Down
8 changes: 4 additions & 4 deletions src/pages/api/v2/calendars/events/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ export default async function handler(req, res) {
});
if(calendarObjects && isValidResultArray(calendarObjects)){
for(const i in calendarObjects){
var type = checkifObjectisVTODO(calendarObjects[i])
// console.log("type", type)
const type = checkifObjectisVTODO(calendarObjects[i].data)
calendarObjects[i]["type"]=type
}
}
res.status(200).json({ version:2, success: true, data: { message: calendarObjects} })
// console.log("calendarObjects", calendarObjects)
return res.status(200).json({ version:2, success: true, data: { message: calendarObjects} })

}else{
return res.status(401).json({ success: false, data: { message: 'ERROR_GENERIC'} })

}

}else{
res.status(401).json({ success: false, data: { message: 'USER_DOESNT_HAVE_ACCESS'} })
return res.status(401).json({ success: false, data: { message: 'USER_DOESNT_HAVE_ACCESS'} })

}

Expand Down

0 comments on commit 7f14824

Please sign in to comment.