mario-education 2.4.256-release → 2.4.258-release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MarioFramework.Education/ClientApp/src/containers/QuestionCategory/hooks/useQuestionCateDetail.d.ts +1 -1
- package/dist/MarioFramework.Education/ClientApp/src/services/questionCategoryService.d.ts +1 -0
- package/dist/index.js +114 -30
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +114 -30
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Filter } from "mario-core";
|
|
2
2
|
export declare const get: (filter?: Filter | undefined) => Promise<import("axios").AxiosResponse<any>>;
|
|
3
|
+
export declare const getParentLevel0: (level?: string | undefined) => Promise<import("axios").AxiosResponse<any>>;
|
|
3
4
|
export declare const getById: (id: number) => Promise<import("axios").AxiosResponse<any>>;
|
|
4
5
|
export declare const create: (data: any) => Promise<import("axios").AxiosResponse<any>>;
|
|
5
6
|
export declare const update: (data: any) => Promise<import("axios").AxiosResponse<any>>;
|
package/dist/index.js
CHANGED
|
@@ -14800,6 +14800,13 @@ var get$i = function get(filter) {
|
|
|
14800
14800
|
params: filter
|
|
14801
14801
|
});
|
|
14802
14802
|
};
|
|
14803
|
+
var getParentLevel0 = function getParentLevel0(level) {
|
|
14804
|
+
return marioCore.api.get(QUESTION_CATE_URL, {
|
|
14805
|
+
params: {
|
|
14806
|
+
level: level
|
|
14807
|
+
}
|
|
14808
|
+
});
|
|
14809
|
+
};
|
|
14803
14810
|
var getById$e = function getById(id) {
|
|
14804
14811
|
return marioCore.api.get(QUESTION_CATE_URL + "/" + id);
|
|
14805
14812
|
};
|
|
@@ -16883,6 +16890,60 @@ var QuestionBankContainer = function QuestionBankContainer() {
|
|
|
16883
16890
|
});
|
|
16884
16891
|
};
|
|
16885
16892
|
|
|
16893
|
+
var QuestionCateSelector = function QuestionCateSelector(_ref) {
|
|
16894
|
+
var isDisabled = _ref.isDisabled,
|
|
16895
|
+
value = _ref.value,
|
|
16896
|
+
onChange = _ref.onChange,
|
|
16897
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["id", "isDisabled", "value", "onChange", "title", "isRequired"]);
|
|
16898
|
+
|
|
16899
|
+
var dispatch = reactRedux.useDispatch();
|
|
16900
|
+
|
|
16901
|
+
var _useState = React.useState([]),
|
|
16902
|
+
questionCategory = _useState[0],
|
|
16903
|
+
setQuestionCategory = _useState[1];
|
|
16904
|
+
|
|
16905
|
+
var getData = React.useCallback(function () {
|
|
16906
|
+
try {
|
|
16907
|
+
var _temp2 = _catch(function () {
|
|
16908
|
+
return Promise.resolve(getParentLevel0("0")).then(function (res) {
|
|
16909
|
+
setQuestionCategory(res.data.items);
|
|
16910
|
+
});
|
|
16911
|
+
}, function (err) {
|
|
16912
|
+
var _err$response, _err$response$data;
|
|
16913
|
+
|
|
16914
|
+
dispatch(marioCore.setAlert({
|
|
16915
|
+
type: "danger",
|
|
16916
|
+
message: ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : _err$response$data.title) || err.message
|
|
16917
|
+
}));
|
|
16918
|
+
});
|
|
16919
|
+
|
|
16920
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
16921
|
+
} catch (e) {
|
|
16922
|
+
return Promise.reject(e);
|
|
16923
|
+
}
|
|
16924
|
+
}, []);
|
|
16925
|
+
React.useEffect(function () {
|
|
16926
|
+
getData();
|
|
16927
|
+
}, []);
|
|
16928
|
+
var options = questionCategory.length > 0 ? questionCategory.map(function (item) {
|
|
16929
|
+
return {
|
|
16930
|
+
id: item.id,
|
|
16931
|
+
label: "" + item.name,
|
|
16932
|
+
value: item.id
|
|
16933
|
+
};
|
|
16934
|
+
}) : [];
|
|
16935
|
+
var initValue = !!value && value.length > 0 ? options.filter(function (item) {
|
|
16936
|
+
return value.includes(item.value);
|
|
16937
|
+
}) : [];
|
|
16938
|
+
return React__default.createElement(marioCore.CustomSelector, Object.assign({
|
|
16939
|
+
options: options,
|
|
16940
|
+
placeholder: "Select category",
|
|
16941
|
+
value: initValue,
|
|
16942
|
+
onChange: onChange,
|
|
16943
|
+
isDisabled: isDisabled
|
|
16944
|
+
}, rest));
|
|
16945
|
+
};
|
|
16946
|
+
|
|
16886
16947
|
var schema$d = yup.object({
|
|
16887
16948
|
name: yup.string().required("Name is required")
|
|
16888
16949
|
});
|
|
@@ -16947,14 +17008,15 @@ var QuestionCateModal = function QuestionCateModal(props, ref) {
|
|
|
16947
17008
|
})), React__default.createElement(reactstrap.Col, {
|
|
16948
17009
|
md: 12,
|
|
16949
17010
|
className: "mb-2"
|
|
16950
|
-
}, React__default.createElement(reactstrap.Label, null, t("parent_category")), React__default.createElement(
|
|
16951
|
-
isDisabled: !!values.id,
|
|
17011
|
+
}, React__default.createElement(reactstrap.Label, null, t("parent_category")), React__default.createElement(QuestionCateSelector, {
|
|
16952
17012
|
onChange: function onChange(e) {
|
|
16953
|
-
formikProps.setFieldValue("parentCategoryId", e.
|
|
17013
|
+
formikProps.setFieldValue("parentCategoryId", e.map(function (i) {
|
|
17014
|
+
return i.value;
|
|
17015
|
+
}));
|
|
16954
17016
|
setEditedTrue();
|
|
16955
17017
|
},
|
|
16956
|
-
|
|
16957
|
-
isMulti:
|
|
17018
|
+
value: values.parentCategoryId,
|
|
17019
|
+
isMulti: true
|
|
16958
17020
|
}))));
|
|
16959
17021
|
});
|
|
16960
17022
|
};
|
|
@@ -17155,11 +17217,13 @@ var useQuestionCateList = function useQuestionCateList() {
|
|
|
17155
17217
|
|
|
17156
17218
|
if (!parent) {
|
|
17157
17219
|
newQuestionCategories = questionCategories.filter(function (q) {
|
|
17158
|
-
return !q.parentCategoryId;
|
|
17220
|
+
return !(q !== null && q !== void 0 && q.parentCategoryId);
|
|
17159
17221
|
});
|
|
17160
17222
|
} else {
|
|
17161
17223
|
newQuestionCategories = questionCategories.filter(function (q) {
|
|
17162
|
-
|
|
17224
|
+
var _q$parentCategoryId;
|
|
17225
|
+
|
|
17226
|
+
return q === null || q === void 0 ? void 0 : (_q$parentCategoryId = q.parentCategoryId) === null || _q$parentCategoryId === void 0 ? void 0 : _q$parentCategoryId.includes(parent.id);
|
|
17163
17227
|
});
|
|
17164
17228
|
}
|
|
17165
17229
|
|
|
@@ -17167,7 +17231,9 @@ var useQuestionCateList = function useQuestionCateList() {
|
|
|
17167
17231
|
return _extends({}, q, {
|
|
17168
17232
|
level: Number.isInteger(parent === null || parent === void 0 ? void 0 : parent.level) ? parent.level + 1 : 0,
|
|
17169
17233
|
hasChildren: questionCategories.findIndex(function (qc) {
|
|
17170
|
-
|
|
17234
|
+
var _qc$parentCategoryId;
|
|
17235
|
+
|
|
17236
|
+
return qc === null || qc === void 0 ? void 0 : (_qc$parentCategoryId = qc.parentCategoryId) === null || _qc$parentCategoryId === void 0 ? void 0 : _qc$parentCategoryId.includes(q.id);
|
|
17171
17237
|
}) >= 0
|
|
17172
17238
|
});
|
|
17173
17239
|
});
|
|
@@ -17178,22 +17244,32 @@ var useQuestionCateList = function useQuestionCateList() {
|
|
|
17178
17244
|
return c.id === parent.id;
|
|
17179
17245
|
});
|
|
17180
17246
|
if (indexOfParent < 0) return;
|
|
17247
|
+
var newCategories = categories;
|
|
17181
17248
|
|
|
17182
17249
|
if (categories[indexOfParent].show) {
|
|
17183
|
-
|
|
17184
|
-
setCategories([].concat(newCategories));
|
|
17250
|
+
newCategories = hideChildren(categories[indexOfParent]);
|
|
17185
17251
|
} else {
|
|
17186
17252
|
var children = getCategoriesByParent(questionCateList, categories[indexOfParent]);
|
|
17187
17253
|
|
|
17188
17254
|
if (children.length > 0) {
|
|
17189
|
-
|
|
17255
|
+
newCategories.splice.apply(newCategories, [indexOfParent + 1, 0].concat(children));
|
|
17256
|
+
newCategories[indexOfParent].show = true;
|
|
17257
|
+
}
|
|
17258
|
+
}
|
|
17190
17259
|
|
|
17191
|
-
|
|
17260
|
+
var indexOpenOthder = categories.findIndex(function (c) {
|
|
17261
|
+
return c.id != parent.id && c.show;
|
|
17262
|
+
});
|
|
17192
17263
|
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
|
|
17264
|
+
if (indexOpenOthder >= 0) {
|
|
17265
|
+
var indexLevel0 = categories.findIndex(function (c, idx) {
|
|
17266
|
+
return c.level == 0 && idx > indexOpenOthder;
|
|
17267
|
+
});
|
|
17268
|
+
newCategories.splice(indexOpenOthder + 1, indexLevel0 - indexOpenOthder - 1);
|
|
17269
|
+
newCategories[indexOpenOthder].show = false;
|
|
17196
17270
|
}
|
|
17271
|
+
|
|
17272
|
+
setCategories([].concat(newCategories));
|
|
17197
17273
|
};
|
|
17198
17274
|
|
|
17199
17275
|
var hideChildren = function hideChildren(parent) {
|
|
@@ -17203,22 +17279,19 @@ var useQuestionCateList = function useQuestionCateList() {
|
|
|
17203
17279
|
if (indexOfParent < 0) return;
|
|
17204
17280
|
var newCategories = categories;
|
|
17205
17281
|
categories.forEach(function (c) {
|
|
17206
|
-
|
|
17282
|
+
var _c$parentCategoryId;
|
|
17283
|
+
|
|
17284
|
+
if (c !== null && c !== void 0 && (_c$parentCategoryId = c.parentCategoryId) !== null && _c$parentCategoryId !== void 0 && _c$parentCategoryId.includes(parent.id)) newCategories = hideChildren(c);
|
|
17207
17285
|
});
|
|
17208
17286
|
newCategories = newCategories.filter(function (c) {
|
|
17209
|
-
|
|
17287
|
+
var _c$parentCategoryId2;
|
|
17288
|
+
|
|
17289
|
+
return !(c !== null && c !== void 0 && (_c$parentCategoryId2 = c.parentCategoryId) !== null && _c$parentCategoryId2 !== void 0 && _c$parentCategoryId2.includes(parent.id));
|
|
17210
17290
|
});
|
|
17211
17291
|
newCategories[indexOfParent].show = false;
|
|
17212
17292
|
return newCategories;
|
|
17213
17293
|
};
|
|
17214
17294
|
|
|
17215
|
-
var removeCatecory = function removeCatecory(categoryId) {
|
|
17216
|
-
var newCategories = categories.filter(function (c) {
|
|
17217
|
-
return c.id !== categoryId;
|
|
17218
|
-
});
|
|
17219
|
-
setCategories([].concat(newCategories));
|
|
17220
|
-
};
|
|
17221
|
-
|
|
17222
17295
|
var removeData = function removeData(id) {
|
|
17223
17296
|
dispatch(marioCore.setLoading(true));
|
|
17224
17297
|
|
|
@@ -17229,24 +17302,35 @@ var useQuestionCateList = function useQuestionCateList() {
|
|
|
17229
17302
|
message: "Do you want to remove this category?",
|
|
17230
17303
|
onConfirm: function () {
|
|
17231
17304
|
try {
|
|
17232
|
-
|
|
17305
|
+
var _temp6 = _catch(function () {
|
|
17306
|
+
return Promise.resolve(remove$e(id)).then(function () {
|
|
17307
|
+
dispatch(marioCore.setAlert({
|
|
17308
|
+
type: "success",
|
|
17309
|
+
message: "Remove category successfully"
|
|
17310
|
+
}));
|
|
17311
|
+
getData();
|
|
17312
|
+
});
|
|
17313
|
+
}, function (err) {
|
|
17314
|
+
var _err$response2, _err$response2$data;
|
|
17315
|
+
|
|
17233
17316
|
dispatch(marioCore.setAlert({
|
|
17234
|
-
type: "
|
|
17235
|
-
message:
|
|
17317
|
+
type: "danger",
|
|
17318
|
+
message: ((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : (_err$response2$data = _err$response2.data) === null || _err$response2$data === void 0 ? void 0 : _err$response2$data.title) || err.message
|
|
17236
17319
|
}));
|
|
17237
|
-
removeCatecory(id);
|
|
17238
17320
|
});
|
|
17321
|
+
|
|
17322
|
+
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
|
|
17239
17323
|
} catch (e) {
|
|
17240
17324
|
return Promise.reject(e);
|
|
17241
17325
|
}
|
|
17242
17326
|
}
|
|
17243
17327
|
}));
|
|
17244
17328
|
} catch (err) {
|
|
17245
|
-
var _err$
|
|
17329
|
+
var _err$response3, _err$response3$data;
|
|
17246
17330
|
|
|
17247
17331
|
dispatch(marioCore.setAlert({
|
|
17248
17332
|
type: "danger",
|
|
17249
|
-
message: ((_err$
|
|
17333
|
+
message: ((_err$response3 = err.response) === null || _err$response3 === void 0 ? void 0 : (_err$response3$data = _err$response3.data) === null || _err$response3$data === void 0 ? void 0 : _err$response3$data.title) || err.message
|
|
17250
17334
|
}));
|
|
17251
17335
|
}
|
|
17252
17336
|
|