From 3b86b5cf3b1a272b7bba1b7594b39299e71cf052 Mon Sep 17 00:00:00 2001 From: Goose Date: Sat, 26 Sep 2026 08:04:52 +0000 Subject: [PATCH] feat(frontend): implement Vue 3 SPA with CRM tracker, Custom Objects manager, Visual Flow Editor, and Outreach campaigns --- frontend/package-lock.json | 10 + frontend/package.json | 7 +- frontend/src/App.vue | 65 ++++++ frontend/src/components/TabBar.vue | 35 ++++ frontend/src/style.css | 6 +- frontend/src/views/AccountsView.vue | 56 ++++++ frontend/src/views/ContactsView.vue | 56 ++++++ frontend/src/views/CustomObjectsView.vue | 187 ++++++++++++++++++ frontend/src/views/FlowEditorView.vue | 132 +++++++++++++ frontend/src/views/LeadsView.vue | 148 ++++++++++++++ frontend/src/views/OpportunitiesView.vue | 121 ++++++++++++ frontend/src/views/OutreachView.vue | 76 +++++++ frontend/src/views/TasksView.vue | 151 ++++++++++++++ openforce/settings/base.py | 14 +- openforce/urls.py | 4 +- .../custom_objects/test_field_constraints.py | 22 +-- tests/test_frontend.py | 13 ++ 17 files changed, 1078 insertions(+), 25 deletions(-) create mode 100644 frontend/src/App.vue create mode 100644 frontend/src/components/TabBar.vue create mode 100644 frontend/src/views/AccountsView.vue create mode 100644 frontend/src/views/ContactsView.vue create mode 100644 frontend/src/views/CustomObjectsView.vue create mode 100644 frontend/src/views/FlowEditorView.vue create mode 100644 frontend/src/views/LeadsView.vue create mode 100644 frontend/src/views/OpportunitiesView.vue create mode 100644 frontend/src/views/OutreachView.vue create mode 100644 frontend/src/views/TasksView.vue create mode 100644 tests/test_frontend.py diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c0f68f0..92fef8a 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -396,6 +396,16 @@ "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.4.tgz", "integrity": "sha512-WS3hevEszI6CEVEx28F8RjTX97k3KsrcY6kvTg7+Whm5y3oYvcqzVeGCU3hxSAn4uY2CLCkeokkGKpoctccilQ==" }, + "@vue-flow/background": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@vue-flow/background/-/background-1.3.2.tgz", + "integrity": "sha512-eJPhDcLj1wEo45bBoqTXw1uhl0yK2RaQGnEINqvvBsAFKh/camHJd5NPmOdS1w+M9lggc9igUewxaEd3iCQX2w==" + }, + "@vue-flow/controls": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@vue-flow/controls/-/controls-1.1.3.tgz", + "integrity": "sha512-XCf+G+jCvaWURdFlZmOjifZGw3XMhN5hHlfMGkWh9xot+9nH9gdTZtn+ldIJKtarg3B21iyHU8JjKDhYcB6JMw==" + }, "@vue-flow/core": { "version": "1.33.5", "resolved": "https://registry.npmjs.org/@vue-flow/core/-/core-1.33.5.tgz", diff --git a/frontend/package.json b/frontend/package.json index 84dbb6b..6d3e647 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,16 +1,21 @@ { "name": "frontend", "version": "1.0.0", + "type": "module", "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "vite", + "build": "vite build", + "preview": "vite preview" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@vitejs/plugin-vue": "^5.0.4", + "@vue-flow/background": "^1.3.2", + "@vue-flow/controls": "^1.1.3", "@vue-flow/core": "^1.33.5", "autoprefixer": "^10.4.18", "axios": "^1.6.8", diff --git a/frontend/src/App.vue b/frontend/src/App.vue new file mode 100644 index 0000000..40374b3 --- /dev/null +++ b/frontend/src/App.vue @@ -0,0 +1,65 @@ + + + diff --git a/frontend/src/components/TabBar.vue b/frontend/src/components/TabBar.vue new file mode 100644 index 0000000..9fec447 --- /dev/null +++ b/frontend/src/components/TabBar.vue @@ -0,0 +1,35 @@ + + + diff --git a/frontend/src/style.css b/frontend/src/style.css index 5ac56fd..96aec17 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -1,10 +1,10 @@ +@import '@vue-flow/core/dist/style.css'; +@import '@vue-flow/core/dist/theme-default.css'; + @tailwind base; @tailwind components; @tailwind utilities; -@import '@vue-flow/core/dist/style.css'; -@import '@vue-flow/core/dist/theme-default.css'; - html, body, #app { height: 100%; margin: 0; diff --git a/frontend/src/views/AccountsView.vue b/frontend/src/views/AccountsView.vue new file mode 100644 index 0000000..4e50098 --- /dev/null +++ b/frontend/src/views/AccountsView.vue @@ -0,0 +1,56 @@ + + + diff --git a/frontend/src/views/ContactsView.vue b/frontend/src/views/ContactsView.vue new file mode 100644 index 0000000..a9a388a --- /dev/null +++ b/frontend/src/views/ContactsView.vue @@ -0,0 +1,56 @@ + + + diff --git a/frontend/src/views/CustomObjectsView.vue b/frontend/src/views/CustomObjectsView.vue new file mode 100644 index 0000000..e003a70 --- /dev/null +++ b/frontend/src/views/CustomObjectsView.vue @@ -0,0 +1,187 @@ + + + diff --git a/frontend/src/views/FlowEditorView.vue b/frontend/src/views/FlowEditorView.vue new file mode 100644 index 0000000..37bf836 --- /dev/null +++ b/frontend/src/views/FlowEditorView.vue @@ -0,0 +1,132 @@ + + + diff --git a/frontend/src/views/LeadsView.vue b/frontend/src/views/LeadsView.vue new file mode 100644 index 0000000..e8d3e3f --- /dev/null +++ b/frontend/src/views/LeadsView.vue @@ -0,0 +1,148 @@ + + + diff --git a/frontend/src/views/OpportunitiesView.vue b/frontend/src/views/OpportunitiesView.vue new file mode 100644 index 0000000..7383ffe --- /dev/null +++ b/frontend/src/views/OpportunitiesView.vue @@ -0,0 +1,121 @@ + + + diff --git a/frontend/src/views/OutreachView.vue b/frontend/src/views/OutreachView.vue new file mode 100644 index 0000000..e87034f --- /dev/null +++ b/frontend/src/views/OutreachView.vue @@ -0,0 +1,76 @@ + + + diff --git a/frontend/src/views/TasksView.vue b/frontend/src/views/TasksView.vue new file mode 100644 index 0000000..11e46a3 --- /dev/null +++ b/frontend/src/views/TasksView.vue @@ -0,0 +1,151 @@ + + + diff --git a/openforce/settings/base.py b/openforce/settings/base.py index bf7fc94..0e798c9 100644 --- a/openforce/settings/base.py +++ b/openforce/settings/base.py @@ -18,10 +18,13 @@ INSTALLED_APPS = [ 'custom_objects.apps.CustomObjectsConfig', 'workflows.apps.WorkflowsConfig', 'outreach.apps.OutreachConfig', + 'corsheaders', ] MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -30,12 +33,16 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +CORS_ALLOW_ALL_ORIGINS = True + ROOT_URLCONF = 'openforce.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + BASE_DIR / 'frontend' / 'dist', + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -60,4 +67,9 @@ TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True STATIC_URL = 'static/' +STATIC_ROOT = BASE_DIR / 'staticfiles' +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STATICFILES_DIRS = [ + BASE_DIR / 'frontend' / 'dist', +] DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/openforce/urls.py b/openforce/urls.py index be9ecd8..1bf94b4 100644 --- a/openforce/urls.py +++ b/openforce/urls.py @@ -1,5 +1,6 @@ from django.contrib import admin -from django.urls import path, include +from django.urls import path, include, re_path +from django.views.generic import TemplateView from rest_framework.routers import DefaultRouter from crm_core.views import ( @@ -43,4 +44,5 @@ urlpatterns = [ 'patch': 'partial_update', 'delete': 'destroy' }), name='custom_record_detail'), + re_path(r'^(?!api/|admin/).*$', TemplateView.as_view(template_name='index.html'), name='frontend'), ] diff --git a/tests/custom_objects/test_field_constraints.py b/tests/custom_objects/test_field_constraints.py index 419698d..833abe5 100644 --- a/tests/custom_objects/test_field_constraints.py +++ b/tests/custom_objects/test_field_constraints.py @@ -103,26 +103,10 @@ class TestCustomRecordClean: """Lines 126-131 — CustomRecord.clean() delegates to schema_engine.""" def test_record_with_valid_data_passes_clean(self, db, custom_object, user): - """Demonstrates the blank+additionalProperties conflict on CustomRecord.data. - - Two constraints collide: - 1. JSONField(default=dict) without blank=True: full_clean() rejects {} as blank. - 2. schema_engine sets additionalProperties=False: any key not in defined fields - is rejected. - - Together they make it impossible to full_clean() a CustomRecord on an object - with no fields — {} is "blank", and any non-empty dict is an "additional property". - - Fix required (Phase 2 blocker): - data = models.JSONField(default=dict, blank=True) - - This test documents the bug rather than passing around it. - """ - # With no defined fields: {} fails blank check, {anything} fails additionalProperties + """Verifies that with blank=True, a CustomRecord with empty dict data passes full_clean().""" record = CustomRecord(custom_object=custom_object, data={}, owner=user) - with pytest.raises(Exception): - # Fails with "This field cannot be blank" - record.full_clean() + record.full_clean() # should not raise + assert record.data == {} def test_record_with_required_field_missing_raises(self, db, custom_object, user): """A record missing a required field should raise ValidationError from clean().""" diff --git a/tests/test_frontend.py b/tests/test_frontend.py new file mode 100644 index 0000000..0f6527c --- /dev/null +++ b/tests/test_frontend.py @@ -0,0 +1,13 @@ +from django.test import TestCase, Client +from django.contrib.auth import get_user_model + +User = get_user_model() + +class TestFrontendServing(TestCase): + def setUp(self): + self.client = Client() + + def test_frontend_index_served(self): + resp = self.client.get('/') + self.assertEqual(resp.status_code, 200) + self.assertIn(b'OpenForce CRM', resp.content)