1
0
Эх сурвалжийг харах

made it so that the documentaiton page runs - current issue: FullCalendar in the JS file

frankvp11 1 жил өмнө
parent
commit
55d4e069f2

+ 10 - 0
nicegui/elements/fullcalendar.py

@@ -8,6 +8,16 @@ from ..events import GenericEventArguments, handle_event
 
 class FullCalendar(Element, component='fullcalendar.js', libraries=['lib/fullcalendar/index.global.min.js']):
     def __init__(self, options: Dict[str, Any], on_click: Optional[Callable] = None) -> None:
+        """ FullCalendar
+            An element that integrates the FullCalendar library (https://fullcalendar.io/) to create an interactive calendar display.
+            
+            
+            :param properties: dictionary of FullCalendar properties for customization, such as "initialView", "slotMinTime", "slotMaxTime", "allDaySlot", "timeZone", "height", and "events".
+            :param on_click: callback function that is called when a calendar event is clicked.
+            :return: FullCalendar element with the specified properties and event handling.
+                
+        """
+
         super().__init__()
         self._props['options'] = options
         

+ 1 - 2
website/documentation.py

@@ -81,7 +81,6 @@ def create_full() -> None:
     load_demo(ui.upload)
     load_demo(ui.chat_message)
     load_demo(ui.element)
-    load_demo(ui.fullcalendar)
     heading('Markdown and HTML')
 
     load_demo(ui.markdown)
@@ -146,7 +145,7 @@ def create_full() -> None:
     load_demo(ui.editor)
     load_demo(ui.code)
     load_demo(ui.json_editor)
-
+    load_demo(ui.fullcalendar)
     heading('Layout')
 
     load_demo(ui.card)

+ 52 - 0
website/more_documentation/full_calendar_documentation.py

@@ -0,0 +1,52 @@
+from nicegui import ui
+
+
+
+def main_demo() -> None:
+    from datetime import datetime
+    def format_date(date_str):
+        # Parse the date string and format it consistently
+        parsed_date = datetime.fromisoformat(date_str)
+        return parsed_date.strftime('%Y-%m-%d %H:%M:%S')
+
+    # def handle_calendar_click(event):
+    #     try:
+    #         start = format_date(event.args['info']['event']['start'])
+    #         end = format_date(event.args['info']['event']['end'])
+    #         title = event.args['info']['event']['title']
+    #     except Exception as e:
+    #         title = None
+
+    #     if title:
+    #         show_event_card(title, start, end)
+
+    # def show_event_card(title, start, end):
+    #     card = ui.card().style("background-color: #f0f0f0; position: absolute; z-index: 10000; top: 50%; left: 50%; transform: translate(-50%, -50%);")
+    #     with card:
+    #         ui.label(title)
+    #         ui.button("Click me to remove the event!", on_click=lambda: (fullcal.remove_event(title=title.strip(), start=start, end=end), card.delete()))
+    #         ui.button("Close", on_click=lambda e: card.delete())
+
+    # def add_event(fullcal):
+
+    ui.add_head_html("<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js'></script>")
+    options = {
+        "initialView": 'timeGridWeek',
+        "slotMinTime": "05:00:00",
+        "slotMaxTime": "22:00:00",
+        "allDaySlot": False,
+        "timeZone": 'local',
+        "height": 'auto',
+        "width": 'auto',
+        "events": []
+    }
+    global fullcal
+
+    # button1 = ui.button("Click me to add event", on_click=lambda: add_event(fullcal))
+    # button = ui.button("Print out all the events", on_click=lambda: ui.notify(fullcal.get_events()))
+    fullcal = ui.fullcalendar(options) # on_click=lambda e: handle_calendar_click(e)
+    fullcal.addevent("Math 1b03", format_date("2023-11-18 09:30:00"), format_date("2023-11-18 10:20:00"), color="red")
+
+
+# main_demo()
+# ui.run()

+ 0 - 48
website/more_documentation/fullcalendar_documentation.py

@@ -1,48 +0,0 @@
-from nicegui import ui
-
-
-
-def main_demo() -> None:
-    from datetime import datetime
-    def format_date(date_str):
-        # Parse the date string and format it consistently
-        parsed_date = datetime.fromisoformat(date_str)
-        return parsed_date.strftime('%Y-%m-%d %H:%M:%S')
-
-    def handle_calendar_click(event):
-        try:
-            start = format_date(event.args['info']['event']['start'])
-            end = format_date(event.args['info']['event']['end'])
-            title = event.args['info']['event']['title']
-        except Exception as e:
-            title = None
-
-        if title:
-            show_event_card(title, start, end)
-
-    def show_event_card(title, start, end):
-        card = ui.card().style("background-color: #f0f0f0; position: absolute; z-index: 10000; top: 50%; left: 50%; transform: translate(-50%, -50%);")
-        with card:
-            ui.label(title)
-            ui.button("Click me to remove the event!", on_click=lambda: (fullcal.remove_event(title=title.strip(), start=start, end=end), card.delete()))
-            ui.button("Close", on_click=lambda e: card.delete())
-
-    def add_event(fullcal):
-        fullcal.addevent("Math 1b03", format_date("2023-11-18 09:30:00"), format_date("2023-11-18 10:20:00"), color="red")
-
-    ui.add_head_html("<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js'></script>")
-    options = {
-        "initialView": 'timeGridWeek',
-        "slotMinTime": "05:00:00",
-        "slotMaxTime": "22:00:00",
-        "allDaySlot": False,
-        "timeZone": 'local',
-        "height": 'auto',
-        "events": []
-    }
-    global fullcal
-    fullcal = ui.fullcalendar(options, on_click=lambda e: handle_calendar_click(e))
-
-    ui.button("Click me to add event", on_click=lambda: add_event(fullcal))
-    ui.button("Print out all the events", on_click=lambda: print(fullcal.get_events()))
-