diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Auto Download All/DownloadAllHandler.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Auto Download All/DownloadAllHandler.cs index 63c6553..39838fe 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Auto Download All/DownloadAllHandler.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Auto Download All/DownloadAllHandler.cs @@ -23,6 +23,8 @@ using System.Collections.Generic; using System.Linq; +using System.Reflection; +using CarterGames.Standalone.NotionData.Filters; using UnityEditor; using UnityEngine; @@ -65,7 +67,7 @@ private static void DownloadAll() } else { - var window = CreateWindow("Download Notion Data"); + var window = GetWindow(true, "Download Notion Data"); window.maxSize = new Vector2(400, 400); } } @@ -158,7 +160,11 @@ private static void ProcessNextAsset() NotionApiRequestHandler.ResetRequestData(); - var requestData = new NotionRequestData(asset, databaseId, assetObject.Fp("databaseApiKey").stringValue, assetObject.Fp("sortProperties").ToSortPropertyArray(), true); + var filters = (NotionFilterContainer) assetObject.GetType().BaseType! + .GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance) + !.GetValue(assetObject.targetObject); + + var requestData = new NotionRequestData(asset, databaseId, assetObject.Fp("databaseApiKey").stringValue, assetObject.Fp("sortProperties").ToSortPropertyArray(), filters, true); NotionApiRequestHandler.WebRequestPostWithAuth(requestData); } diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Creator Tool/NotionDataAssetCreator.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Creator Tool/NotionDataAssetCreator.cs index 773526f..80fc59d 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Creator Tool/NotionDataAssetCreator.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Creator Tool/NotionDataAssetCreator.cs @@ -50,7 +50,7 @@ public sealed class NotionDataAssetCreator : EditorWindow [MenuItem("Tools/Carter Games/Standalone/Notion Data/Asset Creator", priority = 20)] private static void ShowWindow() { - var window = GetWindow(); + var window = GetWindow(true); window.titleContent = new GUIContent("Notion Data Asset Creator"); window.Show(); } diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Inspectors/NotionDataAssetEditor.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Inspectors/NotionDataAssetEditor.cs index c29a9f7..21abfee 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Inspectors/NotionDataAssetEditor.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Inspectors/NotionDataAssetEditor.cs @@ -23,6 +23,8 @@ using System.Linq; using System.Reflection; +using CarterGames.Standalone.NotionData.Filters; +using CarterGames.Standalone.NotionData.ThirdParty; using UnityEditor; using UnityEngine; @@ -50,7 +52,7 @@ public override void OnInspectorGUI() EditorGUILayout.Space(1.5f); GeneralUtilEditor.DrawHorizontalGUILine(); - DrawPropertiesExcluding(serializedObject, "sortProperties"); + DrawPropertiesExcluding(serializedObject, "sortProperties", "filters"); } @@ -67,11 +69,15 @@ private void RenderNotionSettings() EditorGUILayout.BeginHorizontal(); - // Coming... eventually... - // if (GUILayout.Button("Filters")) - // { - // - // } + + var filterTotal = ((NotionFilterContainer) target.GetType().BaseType! + .GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance) + !.GetValue(serializedObject.targetObject)).TotalFilters; + + if (GUILayout.Button($"Filters ({filterTotal})")) + { + EditorWindowFilterGUI.OpenWindow(serializedObject); + } if (GUILayout.Button($"Sorting ({serializedObject.Fp("sortProperties").arraySize})")) { @@ -85,11 +91,11 @@ private void RenderNotionSettings() string.IsNullOrEmpty(serializedObject.Fp("linkToDatabase").stringValue)); - GUILayout.Space(5f); + GUILayout.Space(1.5f); GUI.backgroundColor = Color.green; - if (GUILayout.Button("Download Data")) + if (GUILayout.Button("Download Data", GUILayout.Height(22.5f))) { if (Application.internetReachability == NetworkReachability.NotReachable) { @@ -109,8 +115,13 @@ private void RenderNotionSettings() NotionApiRequestHandler.ResetRequestData(); - var requestData = new NotionRequestData((DataAsset) serializedObject.targetObject, databaseId, serializedObject.Fp("databaseApiKey").stringValue, serializedObject.Fp("sortProperties").ToSortPropertyArray()); - + var sorts = serializedObject.Fp("sortProperties").ToSortPropertyArray(); + var filters = (NotionFilterContainer) target.GetType().BaseType! + .GetField("filters", BindingFlags.NonPublic | BindingFlags.Instance) + !.GetValue(serializedObject.targetObject); + + var requestData = new NotionRequestData((DataAsset) serializedObject.targetObject, databaseId, serializedObject.Fp("databaseApiKey").stringValue, sorts, filters); + NotionApiRequestHandler.WebRequestPostWithAuth(requestData); } @@ -145,15 +156,7 @@ private void OnDataReceived(NotionRequestResult data) private void OnErrorReceived(NotionRequestError error) { - if (error.Message.Contains("Could not find sort property")) - { - EditorUtility.DisplayDialog("Notion Data Download", $"Download failed ({error.Error}):\n{error.Message}", "Continue"); - } - else - { - EditorUtility.DisplayDialog("Notion Data Download", "Download failed, please see console for errors and try again", "Continue"); - } - + EditorUtility.DisplayDialog("Notion Data Download", $"Download failed ({error.Error}):\n{error.Message}", "Continue"); NotionApiRequestHandler.DataReceived.Remove(OnDataReceived); NotionApiRequestHandler.RequestError.Remove(OnErrorReceived); diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider.meta new file mode 100644 index 0000000..9dcc7e6 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b7479832080c51d4283521f6d0b0813f +timeCreated: 1733768828 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs new file mode 100644 index 0000000..4dc9f5b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; + +namespace CarterGames.Standalone.NotionData.Editor +{ + [Serializable] + public class SearchGroup + { + public string Key { get; private set; } + public List> Values { get; private set; } + + + public bool IsValidGroup => !string.IsNullOrEmpty(Key); + + + + public SearchGroup(string groupName, List> values) + { + Key = groupName; + Values = values; + } + + + public SearchGroup(List> values) + { + Key = string.Empty; + Values = values; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs.meta new file mode 100644 index 0000000..dfab9da --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchGroup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b5628ac38dff12846b08e738084e3088 +timeCreated: 1733768830 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs new file mode 100644 index 0000000..6accad2 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class SearchHelper + { + public static SearchTreeEntry CreateGroup(string title, int level) + { + return new SearchTreeGroupEntry(new GUIContent(title)) + { + level = level, + }; + } + + + public static SearchTreeEntry CreateEntry(string title, int level, object data) + { + return new SearchTreeEntry(new GUIContent(" " + title)) + { + level = level, + userData = data + }; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs.meta new file mode 100644 index 0000000..6c8718e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0c25399e68c741641bfcef064e43aaf5 +timeCreated: 1733768830 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs new file mode 100644 index 0000000..7977280 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; + +namespace CarterGames.Standalone.NotionData.Editor +{ + [Serializable] + public class SearchItem + { + public string Key { get; private set; } + public T Value { get; private set; } + + + public static SearchItem Set(string key, T item) + { + return new SearchItem() + { + Key = key, + Value = item + }; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs.meta new file mode 100644 index 0000000..dfb704f --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchItem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dbb7cfa0e93952c40bb56ac8b42ce0fe +timeCreated: 1733768830 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs new file mode 100644 index 0000000..6a992f4 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.Common; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + // Implement to make a search provider for something.... + // You still have to have a way to open it, but it will show the values entered. + public abstract class SearchProvider : ScriptableObject, ISearchWindowProvider + { + public readonly Evt SelectionMade = new Evt(); + + + public abstract string ProviderTitle { get; } + public abstract List> GetEntriesToDisplay(); + public List ToExclude { get; set; } = new List(); + + + public void Open() + { + ToExclude.Clear(); + + SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), this); + } + + + public void Open(T currentValue) + { + ToExclude.Clear(); + ToExclude.Add(currentValue); + + SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), this); + } + + + + public List CreateSearchTree(SearchWindowContext context) + { + var searchList = new List(); + + searchList.Add(new SearchTreeGroupEntry(new GUIContent(ProviderTitle), 0)); + searchList.AddRange(AdditionalEntries); + + return searchList; + } + + + private List AdditionalEntries + { + get + { + var list = new List(); + + foreach (var entries in GetEntriesToDisplay()) + { + if (!entries.IsValidGroup) + { + foreach (var value in entries.Values) + { + if (ToExclude.Contains(value.Value)) continue; + list.Add(SearchHelper.CreateEntry(value.Key, 1, value.Value)); + } + } + else + { + list.Add(SearchHelper.CreateGroup(entries.Key, 1)); + + foreach (var value in entries.Values) + { + if (ToExclude.Contains(value.Value)) continue; + list.Add(SearchHelper.CreateEntry(value.Key, 2, value.Value)); + } + } + } + + return list; + } + } + + + public bool OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context) + { + if (searchTreeEntry == null) return false; + SelectionMade.Raise(searchTreeEntry); + return true; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs.meta new file mode 100644 index 0000000..d6b8aea --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Search Provider/SearchProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a4c0f64c1af0d44499928530cd036e1e +timeCreated: 1733768830 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property.meta b/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property.meta deleted file mode 100644 index 55ebf9f..0000000 --- a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 80afe9bc31f64cd0bfb00924a0d7cfaa -timeCreated: 1726242613 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters.meta new file mode 100644 index 0000000..420e797 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cf839204c3114e3f93a7afed7d1c637f +timeCreated: 1733585214 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs new file mode 100644 index 0000000..a1c6396 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterGroupEditor + { + public static void DrawGroup(SerializedProperty property) + { + var data = property.Fpr("value"); + + for (var i = 0; i < data.Fpr("filterOptions").arraySize; i++) + { + DrawFilter(property, data.Fpr("filterOptions").GetIndex(i), i); + } + } + + + public static void DrawFilter(SerializedProperty baseProp, SerializedProperty property, int index) + { + if (index == 0) + { + DrawFirst(baseProp, property, index); + } + else if (index == 1) + { + DrawSecond(baseProp, property, index); + } + else + { + DrawThirdOnwards(baseProp, property, index); + } + + EditorGUILayout.Space(5f); + } + + + private static void DrawFirst(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Where", GUILayout.Width(40f)); + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawSecond(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + + GUI.backgroundColor = Color.yellow; + if (GUILayout.Button(baseProp.Fpr("value").Fpr("andCheck").boolValue ? "And" : "Or", GUILayout.Width(40f))) + { + baseProp.Fpr("value").Fpr("andCheck").boolValue = !baseProp.Fpr("value").Fpr("andCheck").boolValue; + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + } + GUI.backgroundColor = Color.white; + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawThirdOnwards(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.LabelField(baseProp.Fpr("value").Fpr("andCheck").boolValue ? "And" : "Or", + GUILayout.Width(40f)); + EditorGUI.EndDisabledGroup(); + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawSingleFilter(SerializedProperty baseProp, SerializedProperty property, int index) + { + switch (property.Fpr("typeName").stringValue) + { + case "Rich text": + FilterEditorRichText.DrawFilterOption(baseProp, property, index); + break; + case "CheckBox": + FilterEditorCheckbox.DrawFilterOption(baseProp, property, index); + break; + case "Id": + FilterEditorId.DrawFilterOption(baseProp, property, index); + break; + case "Select": + FilterEditorSelect.DrawFilterOption(baseProp, property, index); + break; + case "Multi Select": + FilterEditorMultiSelect.DrawFilterOption(baseProp, property, index); + break; + case "Number": + FilterEditorNumber.DrawFilterOption(baseProp, property, index); + break; + case "Group": + FilterEditorGroup.DrawGroup(baseProp, property.Fpr("option").Fpr("value").stringValue); + break; + case "Status": + FilterEditorStatus.DrawFilterOption(baseProp, property, index); + break; + case "Date": + FilterEditorDate.DrawFilterOption(baseProp, property, index); + break; + default: + + if (string.IsNullOrEmpty(property.Fpr("typeName").stringValue)) + { + if (GUILayout.Button("Select filter type")) + { + SearchProviderFilterType.GetProvider().SelectionMade.Add(OnSearchSelectionMade); + SearchProviderFilterType.GetProvider().Open(); + + return; + void OnSearchSelectionMade(SearchTreeEntry searchTreeEntry) + { + SearchProviderFilterType.GetProvider().SelectionMade.Remove(OnSearchSelectionMade); + + property.Fpr("typeName").stringValue = ((NotionFilterOption)searchTreeEntry.userData).EditorTypeName; + EditorWindowFilterGUI.SetDefaultValueForType(property.Fpr("option").Fpr("value"), property.Fpr("typeName").stringValue); + + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + } + else + { + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName"), GUIContent.none); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("comparisonEnumIndex"), GUIContent.none); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("value"), GUIContent.none); + } + + break; + } + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs.meta new file mode 100644 index 0000000..5c29acb --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/BaseFilterGroupEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 42a6f6d328c5424bae8040a69ba65a63 +timeCreated: 1733586796 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs new file mode 100644 index 0000000..161ba89 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public class EditorWindowFilterGUI : EditorWindow + { + private static string Id { get; set; } + + public static SerializedProperty target; + + + private static Vector2 ScrollPos + { + get => SessionState.GetVector3(Id, Vector3.zero); + set => SessionState.SetVector3(Id,value); + } + + + public static void OpenWindow(SerializedObject targetSerializedObject) + { + target = targetSerializedObject.Fp("filters").Fpr("filterGroups"); + Id = $"NotionData_FilterGUI_{targetSerializedObject.targetObject.GetInstanceID().ToString()}"; + var window = GetWindow(true, "Edit Filters"); + window.Show(); + } + + + private void OnGUI() + { + if (EditorApplication.isCompiling || target == null) + { + target = new SerializedObject(Selection.activeObject).Fp("filters").Fpr("filterGroups"); + if (target == null) return; + } + + EditorGUILayout.HelpBox("Edit the filters applied to the query when downloading here.", MessageType.Info); + EditorGUILayout.Space(5f); + + ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos); + + if (target.Fpr("list").arraySize <= 0) + { + if (GUILayout.Button("Add filtering")) + { + target.Fpr("list").InsertIndex(0); + target.Fpr("list").GetIndex(0).Fpr("key").stringValue = Guid.NewGuid().ToString(); + target.serializedObject.ApplyModifiedProperties(); + target.serializedObject.Update(); + } + } + else + { + for (var i = 0; i < target.Fpr("list").arraySize; i++) + { + var entry = target.Fpr("list").GetIndex(i); + + if (entry.Fpr("value").Fpr("filterOptions").arraySize <= 0 && i == 0) + { + if (GUILayout.Button("Add Filter Option")) + { + SearchProviderFilterType.GetProvider().SelectionMade.Add(OnSearchSelectionMade); + SearchProviderFilterType.GetProvider().Open(); + + return; + void OnSearchSelectionMade(SearchTreeEntry searchTreeEntry) + { + SearchProviderFilterType.GetProvider().SelectionMade.Remove(OnSearchSelectionMade); + + entry.Fpr("value").Fpr("filterOptions").InsertIndex(entry.Fpr("value").Fpr("filterOptions").arraySize); + var newFilter = entry.Fpr("value").Fpr("filterOptions").GetIndex(entry.Fpr("value").Fpr("filterOptions").arraySize - 1); + newFilter.Fpr("typeName").stringValue = ((NotionFilterOption)searchTreeEntry.userData).EditorTypeName; + newFilter.Fpr("option").Fpr("propertyName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + + SetDefaultValueForType(newFilter.Fpr("option").Fpr("value"), + newFilter.Fpr("typeName").stringValue); + + newFilter.serializedObject.ApplyModifiedProperties(); + newFilter.serializedObject.Update(); + } + } + } + else + { + // Stops nested groups from displaying as normal groups. + if (!string.IsNullOrEmpty(target.Fpr("list").GetIndex(i).Fpr("value").Fpr("nestedId").stringValue)) continue; + + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + FilterGroupEditor.DrawGroup(entry); + + EditorGUILayout.Space(5f); + + if (GUILayout.Button("+ Add filter rule", GUILayout.Width(125f), GUILayout.Height(22.5f))) + { + SearchProviderFilterGroupType.GetProvider(target.Fpr("list").GetIndex(i).Fpr("value").Fpr("nestLevel").intValue).SelectionMade.Add(OnSearchSelectionMade); + SearchProviderFilterGroupType.GetProvider(target.Fpr("list").GetIndex(i).Fpr("value").Fpr("nestLevel").intValue).Open(); + + return; + + void OnSearchSelectionMade(SearchTreeEntry searchTreeEntry) + { + SearchProviderFilterGroupType.GetProvider(target.Fpr("list").GetIndex(i).Fpr("value").Fpr("nestLevel").intValue).SelectionMade.Remove(OnSearchSelectionMade); + + if (int.Parse(searchTreeEntry.userData.ToString()) == 0) + { + // New rule to group + entry.Fpr("value").Fpr("filterOptions") + .InsertIndex(entry.Fpr("value").Fpr("filterOptions").arraySize); + var newFilter = entry.Fpr("value").Fpr("filterOptions") + .GetIndex(entry.Fpr("value").Fpr("filterOptions").arraySize - 1); + newFilter.Fpr("typeName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("propertyName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + newFilter.Fpr("option").Fpr("value").stringValue = string.Empty; + } + else + { + // New group + target.Fpr("list").InsertIndex(target.Fpr("list").arraySize); + target.Fpr("list").GetIndex(target.Fpr("list").arraySize - 1).Fpr("key").stringValue = Guid.NewGuid().ToString(); + target.Fpr("list").GetIndex(target.Fpr("list").arraySize - 1).Fpr("value") + .Fpr("nestedId").stringValue = entry.Fpr("key").stringValue; + target.Fpr("list").GetIndex(target.Fpr("list").arraySize - 1).Fpr("value") + .Fpr("nestLevel").intValue++; + target.Fpr("list").GetIndex(target.Fpr("list").arraySize - 1).Fpr("value") + .Fpr("filterOptions").ClearArray(); + + entry.Fpr("value").Fpr("filterOptions") + .InsertIndex(entry.Fpr("value").Fpr("filterOptions").arraySize); + var newFilter = entry.Fpr("value").Fpr("filterOptions") + .GetIndex(entry.Fpr("value").Fpr("filterOptions").arraySize - 1); + newFilter.Fpr("typeName").stringValue = "Group"; + newFilter.Fpr("option").Fpr("propertyName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + newFilter.Fpr("option").Fpr("value").stringValue = target.Fpr("list").GetIndex(target.Fpr("list").arraySize - 1).Fpr("key").stringValue; + + target.serializedObject.ApplyModifiedProperties(); + target.serializedObject.Update(); + } + + + + target.serializedObject.ApplyModifiedProperties(); + target.serializedObject.Update(); + } + } + + EditorGUILayout.Space(1f); + EditorGUILayout.EndVertical(); + } + } + } + + EditorGUILayout.EndScrollView(); + } + + + public static void SetDefaultValueForType(SerializedProperty property, string typeName) + { + switch (typeName) + { + case "CheckBox": + property.stringValue = "false"; + break; + case "Id": + case "Number": + property.stringValue = "0"; + break; + case "Multi Select": + property.stringValue = JsonUtility.ToJson(new NotionFilterMultiSelectList()); + break; + case "Date": + property.stringValue = JsonUtility.ToJson(new SerializableDateTime(0,0,0,0,0,0, DateTimeKind.Utc)); + break; + default: + property.stringValue = string.Empty; + break; + } + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs.meta new file mode 100644 index 0000000..1c763bb --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/EditorWindowFilterGUI.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c5857c8b71ea49f2af5caa73984f70ba +timeCreated: 1733585223 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search.meta new file mode 100644 index 0000000..780f295 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bf57698c5af94fc7bfd328293409a7bf +timeCreated: 1733768659 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs new file mode 100644 index 0000000..2bde83a --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Collections.Generic; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public class SearchProviderFilterGroupType : SearchProvider + { + private static SearchProviderFilterGroupType Instance; + private static int NestLevel; + public override string ProviderTitle => "Select Filter Type"; + + + public override List> GetEntriesToDisplay() + { + var list = new List>(); + var items = new List>(); + var itemNames = new List() + { + "+ Add filter rule" + }; + + if (NestLevel < 2) + { + itemNames.Add("+ Add filter group"); + } + + for (var i = 0; i < itemNames.Count; i++) + { + items.Add(SearchItem.Set(itemNames[i], i)); + } + + list.Add(new SearchGroup("", items)); + + return list; + } + + + public static SearchProviderFilterGroupType GetProvider(int currentNestLevel) + { + NestLevel = currentNestLevel; + + if (Instance == null) + { + Instance = CreateInstance(); + } + + return Instance; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs.meta new file mode 100644 index 0000000..91f8555 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterGroupType.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5cd41540b5b84421af519ecfc4c2c73f +timeCreated: 1734115169 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs new file mode 100644 index 0000000..a8e82b1 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Collections.Generic; +using System.Linq; +using CarterGames.Standalone.NotionData.Common; +using CarterGames.Standalone.NotionData.Filters; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public class SearchProviderFilterType : SearchProvider + { + private static SearchProviderFilterType Instance; + + public override string ProviderTitle => "Select Notion Filter Type"; + + + public override List> GetEntriesToDisplay() + { + var list = new List>(); + var options = AssemblyHelper.GetClassesOfType(false).Where(t => !ToExclude.Contains(t)); + var items = new List>(); + + foreach (var entry in options) + { + items.Add(SearchItem.Set(entry.EditorTypeName, entry)); + } + + list.Add(new SearchGroup("", items)); + + return list; + } + + + public static SearchProviderFilterType GetProvider() + { + if (Instance == null) + { + Instance = CreateInstance(); + } + + return Instance; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs.meta new file mode 100644 index 0000000..d8db128 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Search/SearchProviderFilterType.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 139b233aeddd4e358309ef3ce530f318 +timeCreated: 1733768896 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific.meta new file mode 100644 index 0000000..a0df3a5 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d5d35ccb379947a5bd14d462386208d8 +timeCreated: 1733588926 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs new file mode 100644 index 0000000..6c381c6 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorCheckbox + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + GUI.backgroundColor = Color.white; + if (GUILayout.Button(property.Fpr("option").Fpr("comparisonEnumIndex").intValue == 0 ? "is not" : "is", GUILayout.Width(147.5f))) + { + if (property.Fpr("option").Fpr("comparisonEnumIndex").intValue == 0) + { + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = 1; + } + else + { + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + } + + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + GUI.backgroundColor = Color.white; + + GUILayout.Space(1.5f); + + EditorGUI.BeginChangeCheck(); + property.Fpr("option").Fpr("value").stringValue = EditorGUILayout.Toggle(bool.Parse(property.Fpr("option").Fpr("value").stringValue)) ? "true" : "false"; + if (EditorGUI.EndChangeCheck()) + { + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs.meta new file mode 100644 index 0000000..598df3f --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorCheckbox.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce31fb97d6104658b3260de01a9d4de4 +timeCreated: 1733768493 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs new file mode 100644 index 0000000..6c32eb8 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorDate + { + private static SerializableDateTime dateTime = new SerializableDateTime(DateTime.MinValue); + + + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilterDateComparison) EditorGUILayout.EnumPopup( + (NotionFilterDateComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + + switch ((NotionFilterDateComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue) + { + case NotionFilterDateComparison.IsEmpty: + case NotionFilterDateComparison.IsNotEmpty: + case NotionFilterDateComparison.NextMonth: + case NotionFilterDateComparison.NextWeek: + case NotionFilterDateComparison.NextYear: + case NotionFilterDateComparison.PastMonth: + case NotionFilterDateComparison.PastWeek: + case NotionFilterDateComparison.PastYear: + case NotionFilterDateComparison.ThisWeek: + break; + default: + GUILayout.Space(1f); + dateTime = JsonUtility.FromJson(property.Fpr("option").Fpr("value").stringValue); + + if (dateTime != null) + { + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.BeginVertical(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Year", GUILayout.Width(65f)); + var year = EditorGUILayout.IntField(GUIContent.none, dateTime.Year); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Month", GUILayout.Width(65f)); + var month = EditorGUILayout.IntField(GUIContent.none, dateTime.Month); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Day", GUILayout.Width(65f)); + var day = EditorGUILayout.IntField(GUIContent.none, dateTime.Day); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Hour", GUILayout.Width(65f)); + var hour = EditorGUILayout.IntField(GUIContent.none, dateTime.Hour); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Minute", GUILayout.Width(65f)); + var min = EditorGUILayout.IntField(GUIContent.none, dateTime.Minute); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Second", GUILayout.Width(65f)); + var seconds = EditorGUILayout.IntField(GUIContent.none, dateTime.Second); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.EndVertical(); + + if (EditorGUI.EndChangeCheck()) + { + dateTime = new SerializableDateTime(year, month, day, hour, min, seconds, + DateTimeKind.Utc); + property.Fpr("option").Fpr("value").stringValue = JsonUtility.ToJson(dateTime); + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + + break; + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs.meta new file mode 100644 index 0000000..8e0cf7c --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorDate.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f661114f1c8947858ab27f3a53be7c34 +timeCreated: 1734124149 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs new file mode 100644 index 0000000..eab6cfd --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorGroup + { + private static string TargetId; + + + public static void DrawGroup(SerializedProperty property, string groupId) + { + TargetId = groupId; + + for (var i = 0; i < EditorWindowFilterGUI.target.Fpr("list").arraySize; i++) + { + if (EditorWindowFilterGUI.target.Fpr("list").GetIndex(i).Fpr("key").stringValue != groupId) continue; + DrawGroupNested(EditorWindowFilterGUI.target.Fpr("list").GetIndex(i)); + } + } + + + private static void DrawGroupNested(SerializedProperty baseProp) + { + var data = baseProp.Fpr("value"); + + EditorGUILayout.BeginVertical("HelpBox"); + + if (data.Fpr("filterOptions").arraySize > 0) + { + for (var i = 0; i < data.Fpr("filterOptions").arraySize; i++) + { + DrawFilter(baseProp, data.Fpr("filterOptions").GetIndex(i), i); + } + + EditorGUILayout.Space(5f); + } + else + { + GUI.backgroundColor = Color.red; + if (GUILayout.Button("Delete filter group")) + { + for (var i = 0; i < EditorWindowFilterGUI.target.Fpr("list").arraySize; i++) + { + if (EditorWindowFilterGUI.target.Fpr("list").GetIndex(i).Fpr("key").stringValue == TargetId) + { + EditorWindowFilterGUI.target.Fpr("list").DeleteIndex(i); + break; + } + + for (var j = 0; j < EditorWindowFilterGUI.target.Fpr("list").GetIndex(i).Fpr("value").Fpr("filterOptions").arraySize; j++) + { + if (EditorWindowFilterGUI.target.Fpr("list").GetIndex(i).Fpr("value").Fpr("filterOptions") + .GetIndex(j).Fpr("option").Fpr("value").stringValue == TargetId) + { + EditorWindowFilterGUI.target.Fpr("list").GetIndex(i).Fpr("value").Fpr("filterOptions").DeleteIndex(j); + break; + } + } + } + + EditorWindowFilterGUI.target.serializedObject.ApplyModifiedProperties(); + EditorWindowFilterGUI.target.serializedObject.Update(); + return; + } + GUI.backgroundColor = Color.white; + } + + if (GUILayout.Button("+ Add filter rule", GUILayout.Width(125f), + GUILayout.Height(22.5f))) + { + var entry = baseProp; + + SearchProviderFilterGroupType.GetProvider(EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("nestLevel").intValue).SelectionMade + .Add(OnSearchSelectionMade); + SearchProviderFilterGroupType.GetProvider(EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("nestLevel").intValue).Open(); + + return; + + void OnSearchSelectionMade(SearchTreeEntry searchTreeEntry) + { + SearchProviderFilterGroupType.GetProvider(EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("nestLevel").intValue).SelectionMade + .Remove(OnSearchSelectionMade); + + if (int.Parse(searchTreeEntry.userData.ToString()) == 0) + { + // New rule to group + entry.Fpr("value").Fpr("filterOptions").InsertIndex(entry.Fpr("value").Fpr("filterOptions").arraySize); + var newFilter = entry.Fpr("value").Fpr("filterOptions") + .GetIndex(entry.Fpr("value").Fpr("filterOptions").arraySize - 1); + newFilter.Fpr("typeName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("propertyName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + newFilter.Fpr("option").Fpr("value").stringValue = string.Empty; + } + else + { + // New group + EditorWindowFilterGUI.target.Fpr("list").InsertIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize); + EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1).Fpr("key") + .stringValue = Guid.NewGuid().ToString(); + EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("nestedId").stringValue = entry.Fpr("key").stringValue; + + EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("nestLevel").intValue++; + + EditorWindowFilterGUI.target.Fpr("list").GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1) + .Fpr("value") + .Fpr("filterOptions").ClearArray(); + + entry.Fpr("value").Fpr("filterOptions") + .InsertIndex(entry.Fpr("value").Fpr("filterOptions").arraySize); + + var newFilter = entry.Fpr("value").Fpr("filterOptions") + .GetIndex(entry.Fpr("value").Fpr("filterOptions").arraySize - 1); + newFilter.Fpr("typeName").stringValue = "Group"; + newFilter.Fpr("option").Fpr("propertyName").stringValue = string.Empty; + newFilter.Fpr("option").Fpr("comparisonEnumIndex").intValue = 0; + newFilter.Fpr("option").Fpr("value").stringValue = EditorWindowFilterGUI.target.Fpr("list") + .GetIndex(EditorWindowFilterGUI.target.Fpr("list").arraySize - 1).Fpr("key").stringValue; + + EditorWindowFilterGUI.target.serializedObject.ApplyModifiedProperties(); + EditorWindowFilterGUI.target.serializedObject.Update(); + } + + + EditorWindowFilterGUI.target.serializedObject.ApplyModifiedProperties(); + EditorWindowFilterGUI.target.serializedObject.Update(); + } + } + + + EditorGUILayout.EndVertical(); + } + + + private static void DrawFilter(SerializedProperty baseProp, SerializedProperty property, int index) + { + if (index == 0) + { + DrawFirst(baseProp, property, index); + } + else if (index == 1) + { + DrawSecond(baseProp, property, index); + } + else + { + DrawThirdOnwards(baseProp, property, index); + } + } + + + private static void DrawFirst(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Where", GUILayout.Width(40f)); + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawSecond(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + + GUI.backgroundColor = Color.yellow; + if (GUILayout.Button(baseProp.Fpr("value").Fpr("andCheck").boolValue ? "And" : "Or", GUILayout.Width(40f))) + { + baseProp.Fpr("value").Fpr("andCheck").boolValue = !baseProp.Fpr("value").Fpr("andCheck").boolValue; + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + } + GUI.backgroundColor = Color.white; + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawThirdOnwards(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginHorizontal(); + + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.LabelField(baseProp.Fpr("value").Fpr("andCheck").boolValue ? "And" : "Or", + GUILayout.Width(40f)); + EditorGUI.EndDisabledGroup(); + + DrawSingleFilter(baseProp, property, index); + + EditorGUILayout.EndHorizontal(); + } + + + private static void DrawSingleFilter(SerializedProperty baseProp, SerializedProperty property, int index) + { + switch (property.Fpr("typeName").stringValue) + { + case "Rich text": + FilterEditorRichText.DrawFilterOption(baseProp, property, index); + break; + case "CheckBox": + FilterEditorCheckbox.DrawFilterOption(baseProp, property, index); + break; + case "Id": + FilterEditorId.DrawFilterOption(baseProp, property, index); + break; + case "Select": + FilterEditorSelect.DrawFilterOption(baseProp, property, index); + break; + case "Multi Select": + FilterEditorMultiSelect.DrawFilterOption(baseProp, property, index); + break; + case "Number": + FilterEditorNumber.DrawFilterOption(baseProp, property, index); + break; + case "Group": + DrawGroup(baseProp, property.Fpr("option").Fpr("value").stringValue); + break; + case "Status": + FilterEditorStatus.DrawFilterOption(baseProp, property, index); + break; + case "Date": + FilterEditorDate.DrawFilterOption(baseProp, property, index); + break; + default: + + if (string.IsNullOrEmpty(property.Fpr("typeName").stringValue)) + { + if (GUILayout.Button("Select filter type")) + { + SearchProviderFilterType.GetProvider().SelectionMade.Add(OnSearchSelectionMade); + SearchProviderFilterType.GetProvider().Open(); + + return; + void OnSearchSelectionMade(SearchTreeEntry searchTreeEntry) + { + SearchProviderFilterType.GetProvider().SelectionMade.Remove(OnSearchSelectionMade); + + property.Fpr("typeName").stringValue = ((NotionFilterOption)searchTreeEntry.userData).EditorTypeName; + EditorWindowFilterGUI.SetDefaultValueForType(property.Fpr("option").Fpr("value"), property.Fpr("typeName").stringValue); + + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + } + else + { + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName"), GUIContent.none); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("comparisonEnumIndex"), GUIContent.none); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("value"), GUIContent.none); + } + + break; + } + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs.meta new file mode 100644 index 0000000..022f132 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorGroup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cad371e317b64a8eac078efbc68e447f +timeCreated: 1734119554 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs new file mode 100644 index 0000000..8c4d1d9 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorId + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilterIdComparison) EditorGUILayout.EnumPopup( + (NotionFilterIdComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + EditorGUI.BeginChangeCheck(); + property.Fpr("option").Fpr("value").stringValue = EditorGUILayout.IntField(int.Parse(property.Fpr("option").Fpr("value").stringValue)).ToString(); + EditorGUILayout.EndHorizontal(); + + if (EditorGUI.EndChangeCheck()) + { + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs.meta new file mode 100644 index 0000000..ba9fad4 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorId.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bb9b9793c7947c6b42c598006fabb4e +timeCreated: 1734089154 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs new file mode 100644 index 0000000..851c85d --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorMultiSelect + { + private static NotionFilterMultiSelectList list = new NotionFilterMultiSelectList(); + + + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilerMultiSelectComparison) EditorGUILayout.EnumPopup( + (NotionFilerMultiSelectComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + + list = JsonUtility.FromJson(property.Fpr("option").Fpr("value").stringValue); + + if (list != null) + { + EditorGUILayout.BeginVertical(); + + if (list.List.Count <= 0) + { + GUI.backgroundColor = Color.green; + if (GUILayout.Button("+ Add option")) + { + list.List.Add(string.Empty); + property.Fpr("option").Fpr("value").stringValue = JsonUtility.ToJson(list); + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + GUI.backgroundColor = Color.white; + } + else + { + for (var i = 0; i < list.List.Count; i++) + { + EditorGUI.BeginChangeCheck(); + + EditorGUILayout.BeginHorizontal(); + + list.List[i] = EditorGUILayout.TextField(GUIContent.none, list.List[i]); + + GUI.backgroundColor = Color.red; + if (GUILayout.Button("-",GUILayout.Width(22.5f))) + { + list.List.RemoveAt(i); + property.Fpr("option").Fpr("value").stringValue = JsonUtility.ToJson(list); + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + break; + } + + GUI.backgroundColor = Color.white; + + EditorGUILayout.EndHorizontal(); + + if (EditorGUI.EndChangeCheck()) + { + property.Fpr("option").Fpr("value").stringValue = JsonUtility.ToJson(list); + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + + GUI.backgroundColor = Color.green; + if (GUILayout.Button("+ Add option")) + { + list.List.Add(string.Empty); + property.Fpr("option").Fpr("value").stringValue = JsonUtility.ToJson(list); + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + GUI.backgroundColor = Color.white; + } + + EditorGUILayout.EndVertical(); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs.meta new file mode 100644 index 0000000..3d8dfa5 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorMultiSelect.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ef8cde07903a41dc85f7c0a4e3027676 +timeCreated: 1734090422 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs new file mode 100644 index 0000000..83eb010 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorNumber + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilterIdComparison) EditorGUILayout.EnumPopup( + (NotionFilterIdComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + EditorGUI.BeginChangeCheck(); + property.Fpr("option").Fpr("value").stringValue = EditorGUILayout.IntField(int.Parse(property.Fpr("option").Fpr("value").stringValue)).ToString(); + + EditorGUILayout.EndHorizontal(); + if (EditorGUI.EndChangeCheck()) + { + property.serializedObject.ApplyModifiedProperties(); + property.serializedObject.Update(); + } + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs.meta new file mode 100644 index 0000000..47916ac --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorNumber.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 40d576e3fe1143a1b8db719328687ad5 +timeCreated: 1734098228 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs new file mode 100644 index 0000000..a595bc9 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorRichText + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({TypeName(property)})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilterRichTextComparison) EditorGUILayout.EnumPopup( + (NotionFilterRichTextComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("value"), GUIContent.none); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + + + private static string TypeName(SerializedProperty property) + { + return property.Fpr("option").Fpr("isRollup").boolValue + ? $"Rollup of {property.Fpr("typeName").stringValue}" + : property.Fpr("typeName").stringValue; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs.meta new file mode 100644 index 0000000..a0ce41b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorRichText.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3440660e6df34990b795e5d424649a0b +timeCreated: 1733768054 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs new file mode 100644 index 0000000..d856d28 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorSelect + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilerSelectComparison) EditorGUILayout.EnumPopup( + (NotionFilerSelectComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("value"), GUIContent.none); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs.meta new file mode 100644 index 0000000..bdf484c --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorSelect.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e2a57177cdc1443da81d39b674c5e01e +timeCreated: 1734090223 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs new file mode 100644 index 0000000..8a84c46 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Editor +{ + public static class FilterEditorStatus + { + public static void DrawFilterOption(SerializedProperty baseProp, SerializedProperty property, int index) + { + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.BeginHorizontal(); + var label = $"{property.Fpr("option").Fpr("propertyName").stringValue} ({property.Fpr("typeName").stringValue})"; + property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); + + if (GUILayout.Button("-", GUILayout.Width(22.5f))) + { + baseProp.Fpr("value").Fpr("filterOptions").DeleteIndex(index); + baseProp.serializedObject.ApplyModifiedProperties(); + baseProp.serializedObject.Update(); + return; + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Space(2f); + + if (property.isExpanded) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("isRollup")); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("propertyName")); + GUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + property.Fpr("option").Fpr("comparisonEnumIndex").intValue = + (int) (NotionFilterStatusComparison) EditorGUILayout.EnumPopup( + (NotionFilterStatusComparison) property.Fpr("option").Fpr("comparisonEnumIndex").intValue, GUILayout.Width(147.5f)); + GUILayout.Space(1f); + EditorGUILayout.PropertyField(property.Fpr("option").Fpr("value"), GUIContent.none); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs.meta new file mode 100644 index 0000000..e37ac82 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Filters/Type Specific/FilterEditorStatus.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3a634308996645b9b5b930b84e55f110 +timeCreated: 1734123927 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/NotionApiRequestHandler.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/NotionApiRequestHandler.cs index a495495..45398b4 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/NotionApiRequestHandler.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/NotionApiRequestHandler.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using CarterGames.Standalone.NotionData.Common; +using CarterGames.Standalone.NotionData.Filters; using CarterGames.Standalone.NotionData.ThirdParty; using UnityEditor; using UnityEngine; @@ -80,7 +81,7 @@ public static void WebRequestPostWithAuth(NotionRequestData data) return; } - var request = PrepareRequest(requestData.Url, requestData.ApiKey, requestData.Sorts); + var request = PrepareRequest(requestData.Url, requestData.ApiKey, requestData.Sorts, requestData.Filter); AsyncOperation asyncOperation = request.SendWebRequest(); @@ -107,7 +108,7 @@ public static void WebRequestPostWithAuth(NotionRequestData data) /// The body to send with the API call. public static void WebRequestPostWithAuth(NotionRequestData data, JSONObject bodyData) { - var request = PrepareRequest(data.Url, data.ApiKey, bodyData, data.Sorts); + var request = PrepareRequest(data.Url, data.ApiKey, bodyData, data.Sorts, data.Filter); AsyncOperation asyncOperation = request.SendWebRequest(); @@ -136,21 +137,32 @@ public static void WebRequestPostWithAuth(NotionRequestData data, JSONObject bod /// The url to use. /// The api key to use. /// The sort properties to apply. + /// The filter to apply. /// A prepared UnityWebRequest. - private static UnityWebRequest PrepareRequest(string url, string apiKey, NotionSortProperty[] sorts = null) + private static UnityWebRequest PrepareRequest(string url, string apiKey, NotionSortProperty[] sorts = null, NotionFilterContainer filters = null) { UnityWebRequest request; - if (sorts == null) + if (sorts == null && filters == null) { request = UnityWebRequest.Post(url, string.Empty); } else { - var body = new JSONObject + var body = new JSONObject(); + + if (sorts != null) + { + if (sorts.Length > 0) + { + body["sorts"] = sorts.ToJsonArray(); + } + } + + if (filters != null) { - ["sorts"] = sorts.ToJsonArray() - }; + body["filter"] = filters.ToFilterJson(); + } request = UnityWebRequest.Put(url, body.ToString()); request.method = "POST"; @@ -171,10 +183,22 @@ private static UnityWebRequest PrepareRequest(string url, string apiKey, NotionS /// The api key to use. /// The body to use in the API call. /// The sort properties to apply. + /// The filter to apply. /// A prepared UnityWebRequest. - private static UnityWebRequest PrepareRequest(string url, string apiKey, JSONObject body, NotionSortProperty[] sorts = null) + private static UnityWebRequest PrepareRequest(string url, string apiKey, JSONObject body, NotionSortProperty[] sorts = null, NotionFilterContainer filter = null) { - body["sorts"] = sorts.ToJsonArray(); + if (sorts != null) + { + if (sorts.Length > 0) + { + body["sorts"] = sorts.ToJsonArray(); + } + } + + if (filter != null) + { + body["filter"] = filter.ToFilterJson(); + } var request = UnityWebRequest.Put(url, body.ToString()); diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Request Data/NotionRequestData.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Request Data/NotionRequestData.cs index eb9189c..5829390 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Request Data/NotionRequestData.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Request Data/NotionRequestData.cs @@ -22,6 +22,7 @@ */ using System.Collections.Generic; +using CarterGames.Standalone.NotionData.Filters; using CarterGames.Standalone.NotionData.ThirdParty; namespace CarterGames.Standalone.NotionData.Editor @@ -39,6 +40,7 @@ public sealed class NotionRequestData private readonly string databaseId; private readonly string apiKey; private readonly NotionSortProperty[] sorts; + private readonly NotionFilterContainer filter; private NotionRequestResult resultData; private readonly bool silentCall; @@ -70,6 +72,12 @@ public sealed class NotionRequestData public NotionSortProperty[] Sorts => sorts; + /// + /// The filtering to apply on requesting the data from the database. + /// + public NotionFilterContainer Filter => filter; + + /// /// The result of the request. /// @@ -93,12 +101,13 @@ public sealed class NotionRequestData /// The api key to get. /// The sorting properties to apply. /// Should the response from the request be hidden from the user? DEF = false - public NotionRequestData(DataAsset requestingAsset, string databaseId, string apiKey, NotionSortProperty[] sorts, bool silentResponse = false) + public NotionRequestData(DataAsset requestingAsset, string databaseId, string apiKey, NotionSortProperty[] sorts, NotionFilterContainer filter, bool silentResponse = false) { this.requestingAsset = requestingAsset; this.databaseId = databaseId; this.apiKey = apiKey; this.sorts = sorts; + this.filter = filter; silentCall = silentResponse; } diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Sort Properties/SortPropertiesWindow.cs similarity index 92% rename from Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs rename to Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Sort Properties/SortPropertiesWindow.cs index b045266..6d8dfeb 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Sort Properties/SortPropertiesWindow.cs @@ -47,7 +47,11 @@ public static void OpenWindow(SerializedObject target) private void OnGUI() { - if (Target == null) return; + if (Target == null) + { + Target = new SerializedObject(Selection.activeObject); + if (Target == null) return; + } EditorGUILayout.HelpBox("Edit the sort properties for this Notion data asset below", MessageType.Info); diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs.meta b/Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Sort Properties/SortPropertiesWindow.cs.meta similarity index 100% rename from Carter Games/Notion Database To Unity/Code/Editor/Editors/Sort Property/SortPropertiesWindow.cs.meta rename to Carter Games/Notion Database To Unity/Code/Editor/Notion/Notion Api/Sort Properties/SortPropertiesWindow.cs.meta diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/AssetInfo.cs b/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/AssetInfo.cs index c3dabad..0d19c97 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/AssetInfo.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/AssetInfo.cs @@ -31,7 +31,7 @@ public static class AssetInfo /// /// The version number of the asset. /// - public static string VersionNumber => "0.3.0"; + public static string VersionNumber => "0.4.0"; /// @@ -40,6 +40,6 @@ public static class AssetInfo /// /// Format is Y/M/D. /// - public static string ReleaseDate => "2024/10/28"; + public static string ReleaseDate => "2024/12/19"; } } \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/Settings Provider/SettingsProviderStandaloneNotionData.cs b/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/Settings Provider/SettingsProviderStandaloneNotionData.cs index 2057864..3f851a0 100644 --- a/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/Settings Provider/SettingsProviderStandaloneNotionData.cs +++ b/Carter Games/Notion Database To Unity/Code/Editor/Supporting Backend/Settings Provider/SettingsProviderStandaloneNotionData.cs @@ -140,7 +140,7 @@ private static void DrawButtons() if (GUILayout.Button("Support Dev", GUILayout.Height(30), GUILayout.MinWidth(100))) { - Application.OpenURL("https://buymeacoffee.com/cartergames"); + Application.OpenURL("https://carter.games/supportdev"); } EditorGUILayout.EndHorizontal(); diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs new file mode 100644 index 0000000..bc18af7 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace CarterGames.Standalone.NotionData.Common +{ + /// + /// A helper class for assembly related logic. + /// + public static class AssemblyHelper + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets the number of classes of the requested type in the project. + /// + /// Check internally to the asset only. + /// The type to find. + /// The total in the project. + public static int CountClassesOfType(bool internalCheckOnly = true) + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + + return assemblies.SelectMany(x => x.GetTypes()) + .Count(x => x.IsClass && typeof(T).IsAssignableFrom(x)); + } + + + /// + /// Gets the number of classes of the requested type in the project. + /// + /// The assemblies to check through. + /// The type to find. + /// The total in the project. + public static int CountClassesOfType(params Assembly[] assemblies) + { + return assemblies.SelectMany(x => x.GetTypes()) + .Count(x => x.IsClass && typeof(T).IsAssignableFrom(x)); + } + + + /// + /// Gets all the classes of the entered type in the project. + /// + /// Check internally to the asset only. + /// The type to find. + /// All the implementations of the entered class. + public static IEnumerable GetClassesOfType(bool internalCheckOnly = true) + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + + return assemblies.SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x) && x.FullName != typeof(T).FullName) + .Select(type => (T)Activator.CreateInstance(type)); + } + + + /// + /// Gets all the classes of the entered type in the project. + /// + /// Check internally to the asset only. + /// The type to find. + /// All the implementations of the entered class. + public static IEnumerable GetClassesNamesOfType(bool internalCheckOnly = true) + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + + return assemblies.SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x) && x.FullName != typeof(T).FullName); + } + + + /// + /// Gets all the classes of the entered type in the project. + /// + /// The assemblies to check through. + /// The type to find. + /// All the implementations of the entered class. + public static IEnumerable GetClassesOfType(params Assembly[] assemblies) + { + return assemblies.SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x) && x.FullName != typeof(T).FullName) + .Select(type => (T)Activator.CreateInstance(type)); + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs.meta new file mode 100644 index 0000000..0649f7c --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Common/AssemblyHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 28db29d5ccc446b4ae3ba822f0dc21ef +timeCreated: 1733769155 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Data Assets/NotionDataAsset.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Data Assets/NotionDataAsset.cs index b1742ff..a94325d 100644 --- a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Data Assets/NotionDataAsset.cs +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Data Assets/NotionDataAsset.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; -using System.Reflection; +using CarterGames.Standalone.NotionData.Filters; using UnityEngine; namespace CarterGames.Standalone.NotionData @@ -38,12 +38,15 @@ namespace CarterGames.Standalone.NotionData /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - + +#if UNITY_EDITOR #pragma warning disable - [SerializeField, HideInInspector] private string linkToDatabase; // Is used in editor space, so ignore the not used warning. - [SerializeField, HideInInspector] private string databaseApiKey; // Is used in editor space, so ignore the not used warning. + [SerializeField, HideInInspector] private string linkToDatabase; + [SerializeField, HideInInspector] private string databaseApiKey; + [SerializeField] private NotionFilterContainer filters; [SerializeField] private List sortProperties; #pragma warning restore +#endif [SerializeField] private List data; diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters.meta new file mode 100644 index 0000000..6b612bf --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0320dee4eb034c988cf4ce03807c394e +timeCreated: 1733579771 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox.meta new file mode 100644 index 0000000..bb8fb99 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4efda2ded02946a0bd4d2c0ea8794c19 +timeCreated: 1733582321 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs new file mode 100644 index 0000000..07ae4d2 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterCheckBox : NotionFilterOption + { + private const string EqualsString = "equals"; + private const string NotEqualsString = "does_not_equal"; + + + private string CheckString => comparisonEnumIndex.Equals(0) ? NotEqualsString : EqualsString; + + + public override string EditorTypeName => "CheckBox"; + + + public NotionFilterCheckBox() {} + + public NotionFilterCheckBox(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + data["checkbox"][CheckString] = value.ToLower(); + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs.meta new file mode 100644 index 0000000..16fa911 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Checkbox/NotionFilterCheckBox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5c07642c8f174d53b0b1db83df4aed17 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date.meta new file mode 100644 index 0000000..8679f5a --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb48e47fdb404b7c8ddcdfe4f0bc63b4 +timeCreated: 1733583355 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs new file mode 100644 index 0000000..e51336f --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Globalization; +using CarterGames.Standalone.NotionData.ThirdParty; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterDate : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterDateComparison.After, "after" }, + { NotionFilterDateComparison.Before, "before" }, + { NotionFilterDateComparison.Equals, "equals" }, + { NotionFilterDateComparison.IsEmpty, "is_empty" }, + { NotionFilterDateComparison.IsNotEmpty, "is_not_empty" }, + { NotionFilterDateComparison.NextMonth, "next_month" }, + { NotionFilterDateComparison.NextWeek, "next_week" }, + { NotionFilterDateComparison.NextYear, "next_year" }, + { NotionFilterDateComparison.OnOrAfter, "on_or_after" }, + { NotionFilterDateComparison.OnOrBefore, "on_or_before" }, + { NotionFilterDateComparison.PastMonth, "past_month" }, + { NotionFilterDateComparison.PastWeek, "past_week" }, + { NotionFilterDateComparison.PastYear, "past_year" }, + { NotionFilterDateComparison.ThisWeek, "this_week" }, + }; + + + private NotionFilterDateComparison Comparison => (NotionFilterDateComparison) comparisonEnumIndex; + + public override string EditorTypeName => "Date"; + + + public NotionFilterDate() {} + public NotionFilterDate(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + // No reason for default as its impossible to hit. +#pragma warning disable + switch (Comparison) +#pragma warning restore + { + case NotionFilterDateComparison.IsEmpty: + case NotionFilterDateComparison.IsNotEmpty: + + data["date"][FilterStringLookup[Comparison]] = true; + break; + case NotionFilterDateComparison.NextMonth: + case NotionFilterDateComparison.NextWeek: + case NotionFilterDateComparison.NextYear: + case NotionFilterDateComparison.PastMonth: + case NotionFilterDateComparison.PastWeek: + case NotionFilterDateComparison.PastYear: + case NotionFilterDateComparison.ThisWeek: + + data["date"][FilterStringLookup[Comparison]] = "{}"; + break; + case NotionFilterDateComparison.OnOrAfter: + case NotionFilterDateComparison.OnOrBefore: + case NotionFilterDateComparison.After: + case NotionFilterDateComparison.Before: + case NotionFilterDateComparison.Equals: + + data["date"][FilterStringLookup[Comparison]] = JsonUtility.FromJson(value).ToString("o", CultureInfo.InvariantCulture); + break; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs.meta new file mode 100644 index 0000000..8ffb10b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDate.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 054fd3a6a3e84b6198dba9906841cbab +timeCreated: 1733583362 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs new file mode 100644 index 0000000..cf45711 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilterDateComparison + { + After, + Before, + Equals, + IsEmpty, + IsNotEmpty, + NextMonth, + NextWeek, + NextYear, + OnOrAfter, + OnOrBefore, + PastMonth, + PastWeek, + PastYear, + ThisWeek, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs.meta new file mode 100644 index 0000000..d63223e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Date/NotionFilterDateComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 48cdd3bb48254683a013b6fc341ebd27 +timeCreated: 1733583394 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs new file mode 100644 index 0000000..3ec9829 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Standalone.NotionData.Filters; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData +{ + public static class FilterJsonHelper + { + public static JSONObject ToJson(this NotionFilterOptionDef filterOptionDef) + { + return filterOptionDef.TypeName switch + { + "CheckBox" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterCheckBox(filterOptionDef.Option)) + : new NotionFilterCheckBox(filterOptionDef.Option).ToJson(), + + "Date" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterDate(filterOptionDef.Option)) + : new NotionFilterDate(filterOptionDef.Option).ToJson(), + + "Id" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterId(filterOptionDef.Option)) + : new NotionFilterId(filterOptionDef.Option).ToJson(), + + "Multi Select" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterMultiSelect(filterOptionDef.Option)) + : new NotionFilterMultiSelect(filterOptionDef.Option).ToJson(), + + "Number" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterNumber(filterOptionDef.Option)) + : new NotionFilterNumber(filterOptionDef.Option).ToJson(), + + "Rich text" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterRichText(filterOptionDef.Option)) + : new NotionFilterRichText(filterOptionDef.Option).ToJson(), + + "Select" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterSelect(filterOptionDef.Option)) + : new NotionFilterSelect(filterOptionDef.Option).ToJson(), + + "Status" => filterOptionDef.Option.IsRollup + ? NotionFilterRollup.ToRollupJson(new NotionFilterStatus(filterOptionDef.Option)) + : new NotionFilterStatus(filterOptionDef.Option).ToJson(), + _ => null + }; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs.meta new file mode 100644 index 0000000..c34a96c --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/FilterJsonHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9257bdaa5d394a838571ed4fbff7fe4e +timeCreated: 1734196069 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id.meta new file mode 100644 index 0000000..1760d77 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: aac6712c650a4aeda8646f80314b098b +timeCreated: 1733582999 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs new file mode 100644 index 0000000..54a6458 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterId : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterIdComparison.DoesNotEqual, "does_not_equal" }, + { NotionFilterIdComparison.Equals, "equals" }, + { NotionFilterIdComparison.GreaterThan, "greater_than" }, + { NotionFilterIdComparison.GreaterThanOrEqualTo, "greater_than_or_equal_to" }, + { NotionFilterIdComparison.LessThan, "less_than" }, + { NotionFilterIdComparison.LessThanOrEqualTo, "less_than_or_equal_to" }, + }; + + + private NotionFilterIdComparison Comparison => (NotionFilterIdComparison) comparisonEnumIndex; + + public override string EditorTypeName => "Id"; + + public NotionFilterId() {} + public NotionFilterId(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + data["unique_id"][FilterStringLookup[Comparison]] = true; + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs.meta new file mode 100644 index 0000000..c724d5e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterId.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ac54b0c7004c4fbc83a0db91588bab1e +timeCreated: 1733583004 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs new file mode 100644 index 0000000..162b601 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilterIdComparison + { + DoesNotEqual, + Equals, + GreaterThan, + GreaterThanOrEqualTo, + LessThan, + LessThanOrEqualTo, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs.meta new file mode 100644 index 0000000..11f009b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Id/NotionFilterIdComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12a4523d74ab484ba0d4e6d9cf500ff1 +timeCreated: 1733583014 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select.meta new file mode 100644 index 0000000..a9a4498 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 312cdb30bc0d429481f2cc282d86f22e +timeCreated: 1733583265 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs new file mode 100644 index 0000000..726adcb --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterMultiSelect : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilerMultiSelectComparison.Contains, "contains" }, + { NotionFilerMultiSelectComparison.DoesNotContain, "does_not_contain" }, + { NotionFilerMultiSelectComparison.IsEmpty, "is_empty" }, + { NotionFilerMultiSelectComparison.IsNotEmpty, "is_not_empty" }, + }; + + + private NotionFilerMultiSelectComparison Comparison => (NotionFilerMultiSelectComparison) comparisonEnumIndex; + + public override string EditorTypeName => "Multi Select"; + + + public NotionFilterMultiSelect() {} + public NotionFilterMultiSelect(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + if (Comparison != NotionFilerMultiSelectComparison.IsEmpty || + Comparison != NotionFilerMultiSelectComparison.IsNotEmpty) + { + data["multi_select"][FilterStringLookup[Comparison]] = JsonUtility.ToJson(value); + } + else + { + data["multi_select"][FilterStringLookup[Comparison]] = true; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs.meta new file mode 100644 index 0000000..b572175 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelect.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 48d6567d59504d608e0d2b8f38fbe72c +timeCreated: 1733583271 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs new file mode 100644 index 0000000..31adf57 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterMultiSelectList + { + [SerializeField] private List list; + + public List List => list; + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs.meta new file mode 100644 index 0000000..84d6cb8 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterMultiSelectList.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f667cb8306af465e97fd92d1ef413545 +timeCreated: 1734090812 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs new file mode 100644 index 0000000..de3e880 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilerMultiSelectComparison + { + Contains, + DoesNotContain, + IsEmpty, + IsNotEmpty, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs.meta new file mode 100644 index 0000000..40e7920 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Multi-Select/NotionFilterSelectComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d952f45e2c794f46b8a952664048a54f +timeCreated: 1733583271 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs new file mode 100644 index 0000000..1be98f1 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Linq; +using CarterGames.Standalone.NotionData.Common; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public sealed class NotionFilterClassDef + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + [SerializeField] private string assembly; + [SerializeField] private string type; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets if the class is valid or not. + /// + public bool IsValid => !string.IsNullOrEmpty(assembly) && !string.IsNullOrEmpty(type); + + + /// + /// The assembly string stored. + /// + public string Assembly => assembly; + + + /// + /// The type string stored. + /// + public string Type => type; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Creates a new definition when called. + /// + /// The assembly to reference. + /// The type to reference. + public NotionFilterClassDef(string assembly, string type) + { + this.assembly = assembly; + this.type = type; + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Converts System.Type to a AssemblyClassDef instance. + /// + /// The type to convert. + /// The created AssemblyClassDef from the type. + public static implicit operator NotionFilterClassDef(Type type) + { + return new NotionFilterClassDef(type.Assembly.FullName, type.FullName); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets the type stored in this AssemblyClassDef. + /// + /// The type to make. + /// The made type or the types default on failure. + public T GetDefinedType() + { + if (!IsValid) + { + Debug.LogError("[GetDefinedType]: Data not valid to generate the defined type"); + return default; + } + + try + { + return AssemblyHelper.GetClassesOfType(false).FirstOrDefault(t => + t.GetType().Assembly.FullName == Assembly && t.GetType().FullName == Type); + } +#pragma warning disable + catch (Exception e) + { + Debug.LogError("[GetDefinedType]: Failed to generate type from stored data. If you have refactored the class selected, please reselect it to update the record."); + return default; + } +#pragma warning restore + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs.meta new file mode 100644 index 0000000..d610cf5 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterClassDef.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 35d4ca01ba3c403293fa349cd8884fd5 +timeCreated: 1733773723 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs new file mode 100644 index 0000000..09717fe --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Linq; +using System.Text; +using CarterGames.Standalone.NotionData.Common; +using CarterGames.Standalone.NotionData.ThirdParty; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterContainer + { + [SerializeField] private SerializableDictionary filterGroups; + + + public int TotalFilters + { + get + { + var total = 0; + + foreach (var group in filterGroups) + { + foreach (var entry in group.Value.FilterOptions) + { + if (entry.TypeName == "Group") continue; + total++; + } + } + + return total; + } + } + + + public JSONObject ToFilterJson() + { + var json = new JSONObject(); + + foreach (var group in filterGroups) + { + if (group.Value.IsNested) continue; + + var type = group.Value.IsAndCheck ? "and" : "or"; + json[type] = new JSONArray(); + + foreach (var entry in group.Value.FilterOptions) + { + if (entry.TypeName == "Group") + { + var groupData = filterGroups.FirstOrDefault(t => t.Key == entry.Option.Value); + var groupJson = new JSONObject(); + + foreach (var groupEntry in groupData.Value.FilterOptions) + { + var groupType = groupData.Value.IsAndCheck ? "and" : "or"; + groupJson[groupType].Add(groupEntry.ToJson()); + } + + json[type].Add(groupJson); + continue; + } + + json[type].Add(entry.ToJson()); + } + } + + return json; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs.meta new file mode 100644 index 0000000..c4d9f2d --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterContainer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5d5b11445cd2428e891aaa9e8ad0cc09 +timeCreated: 1733579878 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs new file mode 100644 index 0000000..c684f4a --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterGroup : NotionFilterOption + { + [SerializeField] private bool andCheck; + [SerializeField] private string nestedId; + [SerializeField] private int nestLevel; + [SerializeField] private NotionFilterOptionDef[] filterOptions; + + public override string EditorTypeName => "Group"; + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs.meta new file mode 100644 index 0000000..b56ff3a --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGroup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e45368a14e4244ffb9738cf8ee1d78f4 +timeCreated: 1733586668 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs new file mode 100644 index 0000000..73ea3f5 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterGrouping + { + [SerializeField] private bool andCheck; + [SerializeField] private string nestedId; + [SerializeField] private int nestLevel; + [SerializeField] private NotionFilterOptionDef[] filterOptions; + + + public bool IsAndCheck => andCheck; + public bool IsNested => !string.IsNullOrEmpty(nestedId); + public string NestedId => nestedId; + public NotionFilterOptionDef[] FilterOptions => filterOptions; + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs.meta new file mode 100644 index 0000000..6856f25 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterGrouping.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e2b41ad87b5e45ff9a23c46fb4ab8da0 +timeCreated: 1733585473 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs new file mode 100644 index 0000000..ce53a3f --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.ThirdParty; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterOption + { + [SerializeField] protected string propertyName; + [SerializeField] protected string value; + [SerializeField] protected int comparisonEnumIndex; + [SerializeField] protected bool isRollup; + [SerializeField] protected int rollupComparisonEnumIndex; + + + public string PropertyName => propertyName; + public string Value => value; + public int ComparisonEnumIndex => comparisonEnumIndex; + public bool IsRollup => isRollup; + public int RollupComparisonEnumIndex => rollupComparisonEnumIndex; + public virtual string EditorTypeName { get; } + + + + public virtual JSONObject ToJson() + { + return null; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs.meta new file mode 100644 index 0000000..3e6ff98 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/NotionFilterOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d4ed3260d2244bc3b5def8f7e3664e0f +timeCreated: 1733580935 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number.meta new file mode 100644 index 0000000..960f50a --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4bf0060fbe8048fca535ddfb96bb4d27 +timeCreated: 1733582300 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs new file mode 100644 index 0000000..cc5d372 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterNumber : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterNumberComparison.DoesNotEqual, "does_not_equal" }, + { NotionFilterNumberComparison.Equals, "equals" }, + { NotionFilterNumberComparison.GreaterThan, "greater_than" }, + { NotionFilterNumberComparison.GreaterThanOrEqualTo, "greater_than_or_equal_to" }, + { NotionFilterNumberComparison.IsEmpty, "is_empty" }, + { NotionFilterNumberComparison.IsNotEmpty, "is_not_empty" }, + { NotionFilterNumberComparison.LessThan, "less_than" }, + { NotionFilterNumberComparison.LessThanOrEqualTo, "less_than_or_equal_to" }, + }; + + + private NotionFilterNumberComparison Comparison => (NotionFilterNumberComparison) comparisonEnumIndex; + public override string EditorTypeName => "Number"; + + + public NotionFilterNumber() {} + public NotionFilterNumber(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + if (Comparison != NotionFilterNumberComparison.IsEmpty || + Comparison != NotionFilterNumberComparison.IsNotEmpty) + { + data["number"][FilterStringLookup[Comparison]] = value.ToString(); + } + else + { + data["number"][FilterStringLookup[Comparison]] = true; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs.meta new file mode 100644 index 0000000..90052c8 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumber.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 48e456b51a314abd999c330fd8246ecb +timeCreated: 1733581607 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs new file mode 100644 index 0000000..006aa3b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilterNumberComparison + { + DoesNotEqual, + Equals, + GreaterThan, + GreaterThanOrEqualTo, + IsEmpty, + IsNotEmpty, + LessThan, + LessThanOrEqualTo, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs.meta new file mode 100644 index 0000000..18b583c --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Number/NotionFilterNumberComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ddf125c0c91f461080014c54437be083 +timeCreated: 1733581648 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text.meta new file mode 100644 index 0000000..d1b2610 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c51adef42f1745439bbcd7d356e313b3 +timeCreated: 1733582304 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs new file mode 100644 index 0000000..f7d12c3 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterRichText : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterRichTextComparison.Contains, "contains" }, + { NotionFilterRichTextComparison.DoesNotContain, "does_not_contain" }, + { NotionFilterRichTextComparison.DoesNotEqual, "does_not_equal" }, + { NotionFilterRichTextComparison.EndsWith, "ends_with" }, + { NotionFilterRichTextComparison.Equals, "equals" }, + { NotionFilterRichTextComparison.IsEmpty, "is_empty" }, + { NotionFilterRichTextComparison.IsNotEmpty, "is_not_empty" }, + { NotionFilterRichTextComparison.StartsWith, "starts_with" }, + }; + + + private NotionFilterRichTextComparison Comparison => (NotionFilterRichTextComparison) comparisonEnumIndex; + + + public override string EditorTypeName => "Rich text"; + + public NotionFilterRichText() {} + public NotionFilterRichText(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + if (Comparison != NotionFilterRichTextComparison.IsEmpty || + Comparison != NotionFilterRichTextComparison.IsNotEmpty) + { + data["rich_text"][FilterStringLookup[Comparison]] = value.ToString(); + } + else + { + data["rich_text"][FilterStringLookup[Comparison]] = true; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs.meta new file mode 100644 index 0000000..f3db0dc --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichText.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d19e63d1c8241c1b8068d4f92574860 +timeCreated: 1733582275 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs new file mode 100644 index 0000000..80d0e86 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilterRichTextComparison + { + Contains, + DoesNotContain, + DoesNotEqual, + EndsWith, + Equals, + IsEmpty, + IsNotEmpty, + StartsWith, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs.meta new file mode 100644 index 0000000..b1f1b8b --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rich Text/NotionFilterRichTextComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6204416acaa04da0a4aeb52f38318c52 +timeCreated: 1733582341 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup.meta new file mode 100644 index 0000000..6addbb9 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1ab5d4b81ac14ff8b9845a1305b7c1b1 +timeCreated: 1734212302 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs new file mode 100644 index 0000000..2a64d5e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + public static class NotionFilterRollup + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterRollupComparison.Any, "any" }, + { NotionFilterRollupComparison.Every, "every" }, + { NotionFilterRollupComparison.None, "none" }, + }; + + + public static JSONObject ToRollupJson(NotionFilterOption filterOptionDef) + { + var data = new JSONObject(); + + data["property"] = filterOptionDef.PropertyName; + data["rollup"][FilterStringLookup[(NotionFilterRollupComparison) filterOptionDef.RollupComparisonEnumIndex]] = filterOptionDef.ToJson(); + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs.meta new file mode 100644 index 0000000..279ea9e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollup.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 791b94cee92e4b07a19d6e2efc5c2c84 +timeCreated: 1734212314 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs new file mode 100644 index 0000000..50b39a1 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData +{ + public enum NotionFilterRollupComparison + { + Any, + Every, + None, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs.meta new file mode 100644 index 0000000..dc66f98 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Rollup/NotionFilterRollupComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0256ae0b77e44fad8378a5302ffdb82e +timeCreated: 1734212396 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select.meta new file mode 100644 index 0000000..573a5a7 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 87918b207b3940dcb493292c04080eca +timeCreated: 1733582519 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs new file mode 100644 index 0000000..c782a6e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterSelect : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilerSelectComparison.Equals, "equals" }, + { NotionFilerSelectComparison.DoesNotEqual, "does_not_equal" }, + { NotionFilerSelectComparison.IsEmpty, "is_empty" }, + { NotionFilerSelectComparison.IsNotEmpty, "is_not_empty" }, + }; + + + private NotionFilerSelectComparison Comparison => (NotionFilerSelectComparison) comparisonEnumIndex; + + public override string EditorTypeName => "Select"; + + public NotionFilterSelect() {} + public NotionFilterSelect(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + if (Comparison != NotionFilerSelectComparison.IsEmpty || + Comparison != NotionFilerSelectComparison.IsNotEmpty) + { + data["select"][FilterStringLookup[Comparison]] = value.ToString(); + } + else + { + data["select"][FilterStringLookup[Comparison]] = true; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs.meta new file mode 100644 index 0000000..a944455 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelect.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 78da8652f09a44eda126d5f6e7a8938e +timeCreated: 1733582525 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs new file mode 100644 index 0000000..2f86e7e --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilerSelectComparison + { + Equals, + DoesNotEqual, + IsEmpty, + IsNotEmpty, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs.meta new file mode 100644 index 0000000..0c233e6 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Select/NotionFilterSelectComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8fa88e7d4e5f46e1a87b6788ab58ee52 +timeCreated: 1733582534 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status.meta new file mode 100644 index 0000000..4019e1d --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2a86304a8c6d4e8b80d3263dce54529c +timeCreated: 1733582789 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs new file mode 100644 index 0000000..c86e03f --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using CarterGames.Standalone.NotionData.ThirdParty; + +namespace CarterGames.Standalone.NotionData.Filters +{ + [Serializable] + public class NotionFilterStatus : NotionFilterOption + { + private static readonly Dictionary FilterStringLookup = + new Dictionary() + { + { NotionFilterStatusComparison.Equals, "equals" }, + { NotionFilterStatusComparison.DoesNotEqual, "does_not_equal" }, + { NotionFilterStatusComparison.IsEmpty, "is_empty" }, + { NotionFilterStatusComparison.IsNotEmpty, "is_not_empty" }, + }; + + + private NotionFilterStatusComparison Comparison => (NotionFilterStatusComparison) comparisonEnumIndex; + + public override string EditorTypeName => "Status"; + + + public NotionFilterStatus() {} + public NotionFilterStatus(NotionFilterOption filterOption) + { + propertyName = filterOption.PropertyName; + value = filterOption.Value; + comparisonEnumIndex = filterOption.ComparisonEnumIndex; + isRollup = filterOption.IsRollup; + } + + public override JSONObject ToJson() + { + var data = new JSONObject(); + + if (!isRollup) + { + data["property"] = propertyName; + } + + if (Comparison != NotionFilterStatusComparison.IsEmpty || + Comparison != NotionFilterStatusComparison.IsNotEmpty) + { + data["status"][FilterStringLookup[Comparison]] = value.ToString(); + } + else + { + data["status"][FilterStringLookup[Comparison]] = true; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs.meta new file mode 100644 index 0000000..3f9dd04 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatus.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8b0f85cb15fb4fc8b98522c7527ceff1 +timeCreated: 1733582795 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs new file mode 100644 index 0000000..eba3632 --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Standalone.NotionData.Filters +{ + public enum NotionFilterStatusComparison + { + Equals, + DoesNotEqual, + IsEmpty, + IsNotEmpty, + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs.meta new file mode 100644 index 0000000..054baad --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/Filters/Status/NotionFilterStatusComparison.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ddfca437baa64c1596d12059bbdb9897 +timeCreated: 1733582804 \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs new file mode 100644 index 0000000..6e36fef --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Standalone.NotionData.Filters; +using UnityEngine; + +namespace CarterGames.Standalone.NotionData +{ + [Serializable] + public class NotionFilterOptionDef + { + [SerializeField] private string typeName; + [SerializeField] private NotionFilterOption option; + + public string TypeName => typeName; + public NotionFilterOption Option => option; + } +} \ No newline at end of file diff --git a/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs.meta b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs.meta new file mode 100644 index 0000000..851a0fb --- /dev/null +++ b/Carter Games/Notion Database To Unity/Code/Runtime/Notion/NotionFilterOptionDef.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 128315b02f22482db47122d56a12d7fb +timeCreated: 1733779216 \ No newline at end of file diff --git a/README.md b/README.md index 641a970..001ce13 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ A flexible system to import Notion databases into a Unity scriptable object for * [Unity Setup](#-unity-setup) * [Downloading Data](#downloading-the-data) * [Sorting Properties](#sorting-properties) + * [Filters](#filters) * [Wrapper Classes](#wrapper-classes) * [Post Download Logic](#post-download-logic) * [Updating all assets](#updating-all-assets) @@ -47,7 +48,7 @@ A flexible system to import Notion databases into a Unity scriptable object for # Features - Download databases of any size. -- Apply sorting to data to order it just as it is in a Notion database view. +- Apply sorting and filters to data to order it just as it is in a Notion database view. - Automatic parsing of data into their field types. - Support for most useful Notion data properties. - Automatic API key removal on build creation for security. @@ -58,7 +59,7 @@ A flexible system to import Notion databases into a Unity scriptable object for # Planned Features -- Support for applying filters when downloading a Notion database. +- None at the moment other than general support where needed.

@@ -187,11 +188,26 @@ Then just fill the fields on the data asset (make one from the ```CreateAssetMen ## Sorting Properties -You can apply sorting properties to your download requests by adding them to the sort properties list in the inspector. The text for each entry is the Notion property name you want to sort by, with the tick box set to if you want to sort ascending for that property. The order of the sort properties in the list defines the order they are used, just like in Notion. +You can apply sorting properties to your download requests by adding them to the sort properties list in the inspector. The text for each entry is the Notion property name you want to sort by, with the tick box set to if you want to sort ascending for that property. The order of the sort properties in the list defines the order they are used, just like in Notion. -The editor for this will be improved at some point. +![image](https://github.com/user-attachments/assets/a9768b81-77ea-41a5-be95-42e40b887e9f) +
+![image](https://github.com/user-attachments/assets/b69ce981-2375-4c3f-ac71-6fdb175479fc) + + +
-![image](https://github.com/user-attachments/assets/e35eab63-6e8a-4a4e-b866-b3810697fbee) + +## Filters +As of 0.4.x you can also apply filters to the download requests by using the filters window. This window more or less mimic’s Notion’s filters GUI. This setup supports the property types the system currently supports reading. The only notable difference is with rollup support. It is supported, but you’ll have to use the type the rollup is displaying and then define it as a rollup of that type for it to work. + +![image](https://github.com/user-attachments/assets/78950c77-8f81-4aac-8036-7aadf9637a85) +

+Notion Example
+![image](https://github.com/user-attachments/assets/cdbaddf2-4446-4df8-a841-d40819ca4602) +

+Unity Example
+![image](https://github.com/user-attachments/assets/bba720f5-bb14-41c9-818e-ef776f77c303)
diff --git a/package.json b/package.json index cda4c21..cd529f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "games.carter.standalone.notiondata", - "version": "0.3.0", + "version": "0.4.0", "displayName": "Notion Data (Standalone)", "description": "A system to import Notion databases into a Unity scriptable object for use in Unity projects. This is a standalone version of the system in the Cart library of the same name.", "unity": "2020.3",