diff --git a/CTFd/themes/admin/assets/js/components/configs/fields/Field.vue b/CTFd/themes/admin/assets/js/components/configs/fields/Field.vue index 4546514c..f02bea77 100644 --- a/CTFd/themes/admin/assets/js/components/configs/fields/Field.vue +++ b/CTFd/themes/admin/assets/js/components/configs/fields/Field.vue @@ -122,7 +122,7 @@ export default { saveField: function() { let body = this.field; if (this.persistedField()) { - CTFd.fetch(`/api/v1/fields/${this.field.id}`, { + CTFd.fetch(`/api/v1/configs/fields/${this.field.id}`, { method: "PATCH", credentials: "same-origin", headers: { @@ -145,7 +145,7 @@ export default { } }); } else { - CTFd.fetch(`/api/v1/fields`, { + CTFd.fetch(`/api/v1/configs/fields`, { method: "POST", credentials: "same-origin", headers: { @@ -172,7 +172,7 @@ export default { deleteField: function() { if (confirm("Are you sure you'd like to delete this field?")) { if (this.persistedField()) { - CTFd.fetch(`/api/v1/fields/${this.field.id}`, { + CTFd.fetch(`/api/v1/configs/fields/${this.field.id}`, { method: "DELETE", credentials: "same-origin", headers: { diff --git a/CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue b/CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue index 51ea9a06..a6b655c9 100644 --- a/CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue +++ b/CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue @@ -41,7 +41,7 @@ export default { }, methods: { loadFields: function() { - CTFd.fetch("/api/v1/fields?type=user", { + CTFd.fetch("/api/v1/configs/fields?type=user", { method: "GET", credentials: "same-origin", headers: { diff --git a/CTFd/themes/admin/static/js/components.dev.js b/CTFd/themes/admin/static/js/components.dev.js index 2076d5d3..71ab3d6f 100644 --- a/CTFd/themes/admin/static/js/components.dev.js +++ b/CTFd/themes/admin/static/js/components.dev.js @@ -176,7 +176,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { ; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _ezq = __webpack_require__(/*! core/ezq */ \"./CTFd/themes/core/assets/js/ezq.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n props: {\n index: Number,\n initialField: Object\n },\n data: function data() {\n return {\n field: this.initialField\n };\n },\n methods: {\n persistedField: function persistedField() {\n // We're using Math.random() for unique IDs so new items have IDs < 1\n // Real items will have an ID > 1\n return this.field.id >= 1;\n },\n saveField: function saveField() {\n var _this = this;\n\n var body = this.field;\n\n if (this.persistedField()) {\n _CTFd.default.fetch(\"/api/v1/fields/\".concat(this.field.id), {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this.field = response.data;\n (0, _ezq.ezToast)({\n title: \"Success\",\n body: \"Field has been updated!\",\n delay: 1000\n });\n }\n });\n } else {\n _CTFd.default.fetch(\"/api/v1/fields\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this.field = response.data;\n (0, _ezq.ezToast)({\n title: \"Success\",\n body: \"Field has been created!\",\n delay: 1000\n });\n }\n });\n }\n },\n deleteField: function deleteField() {\n var _this2 = this;\n\n if (confirm(\"Are you sure you'd like to delete this field?\")) {\n if (this.persistedField()) {\n _CTFd.default.fetch(\"/api/v1/fields/\".concat(this.field.id), {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this2.$emit(\"remove-field\", _this2.index);\n }\n });\n } else {\n this.$emit(\"remove-field\", this.index);\n }\n }\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/components/configs/fields/Field.vue?./node_modules/babel-loader/lib??ref--0!./node_modules/vue-loader/lib??vue-loader-options"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _ezq = __webpack_require__(/*! core/ezq */ \"./CTFd/themes/core/assets/js/ezq.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n props: {\n index: Number,\n initialField: Object\n },\n data: function data() {\n return {\n field: this.initialField\n };\n },\n methods: {\n persistedField: function persistedField() {\n // We're using Math.random() for unique IDs so new items have IDs < 1\n // Real items will have an ID > 1\n return this.field.id >= 1;\n },\n saveField: function saveField() {\n var _this = this;\n\n var body = this.field;\n\n if (this.persistedField()) {\n _CTFd.default.fetch(\"/api/v1/configs/fields/\".concat(this.field.id), {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this.field = response.data;\n (0, _ezq.ezToast)({\n title: \"Success\",\n body: \"Field has been updated!\",\n delay: 1000\n });\n }\n });\n } else {\n _CTFd.default.fetch(\"/api/v1/configs/fields\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(body)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this.field = response.data;\n (0, _ezq.ezToast)({\n title: \"Success\",\n body: \"Field has been created!\",\n delay: 1000\n });\n }\n });\n }\n },\n deleteField: function deleteField() {\n var _this2 = this;\n\n if (confirm(\"Are you sure you'd like to delete this field?\")) {\n if (this.persistedField()) {\n _CTFd.default.fetch(\"/api/v1/configs/fields/\".concat(this.field.id), {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success === true) {\n _this2.$emit(\"remove-field\", _this2.index);\n }\n });\n } else {\n this.$emit(\"remove-field\", this.index);\n }\n }\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/components/configs/fields/Field.vue?./node_modules/babel-loader/lib??ref--0!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -188,7 +188,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { ; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ./Field.vue */ \"./CTFd/themes/admin/assets/js/components/configs/fields/Field.vue\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"FieldList\",\n components: {\n Field: _Field.default\n },\n props: {},\n data: function data() {\n return {\n fields: []\n };\n },\n methods: {\n loadFields: function loadFields() {\n var _this = this;\n\n _CTFd.default.fetch(\"/api/v1/fields?type=user\", {\n method: \"GET\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n _this.fields = response.data;\n });\n },\n addField: function addField() {\n this.fields.push({\n id: Math.random(),\n type: \"user\",\n field_type: \"text\",\n name: \"\",\n description: \"\",\n editable: false,\n required: false,\n public: false\n });\n },\n removeField: function removeField(index) {\n this.fields.splice(index, 1);\n console.log(this.fields);\n }\n },\n created: function created() {\n this.loadFields();\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue?./node_modules/babel-loader/lib??ref--0!./node_modules/vue-loader/lib??vue-loader-options"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ./Field.vue */ \"./CTFd/themes/admin/assets/js/components/configs/fields/Field.vue\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"FieldList\",\n components: {\n Field: _Field.default\n },\n props: {},\n data: function data() {\n return {\n fields: []\n };\n },\n methods: {\n loadFields: function loadFields() {\n var _this = this;\n\n _CTFd.default.fetch(\"/api/v1/configs/fields?type=user\", {\n method: \"GET\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n _this.fields = response.data;\n });\n },\n addField: function addField() {\n this.fields.push({\n id: Math.random(),\n type: \"user\",\n field_type: \"text\",\n name: \"\",\n description: \"\",\n editable: false,\n required: false,\n public: false\n });\n },\n removeField: function removeField(index) {\n this.fields.splice(index, 1);\n console.log(this.fields);\n }\n },\n created: function created() {\n this.loadFields();\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/components/configs/fields/FieldList.vue?./node_modules/babel-loader/lib??ref--0!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }),