mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
new menuDataviewFilter
This commit is contained in:
parent
a9edf363c8
commit
62b737be94
8 changed files with 45 additions and 34 deletions
|
@ -23,6 +23,7 @@ const TIMEOUT_UPDATE = 600 * 1000;
|
|||
const MIN_WIDTH = 752;
|
||||
const MIN_HEIGHT = 480;
|
||||
const KEYTAR_SERVICE = 'Anytype';
|
||||
const CONFIG_NAME = 'devconfig';
|
||||
|
||||
let env = {};
|
||||
try { env = JSON.parse(fs.readFileSync(envPath)); } catch (e) {};
|
||||
|
@ -331,7 +332,7 @@ function createWindow () {
|
|||
};
|
||||
});
|
||||
|
||||
storage.get('devconfig', (error, data) => {
|
||||
storage.get(CONFIG_NAME, (error, data) => {
|
||||
config = data || {};
|
||||
config.channel = String(config.channel || defaultChannel);
|
||||
|
||||
|
@ -571,7 +572,7 @@ function setChannel (channel) {
|
|||
|
||||
function setConfig (obj, callBack) {
|
||||
config = Object.assign(config, obj);
|
||||
storage.set('config', config, (error) => {
|
||||
storage.set(CONFIG_NAME, config, (error) => {
|
||||
send('config', config);
|
||||
if (callBack) {
|
||||
callBack(error);
|
||||
|
|
|
@ -301,6 +301,7 @@
|
|||
"linkPreviewEdit": { "en": "Edit link" },
|
||||
"linkPreviewUnlink": { "en": "Unlink" },
|
||||
|
||||
"filterConditionNone": { "en": "all" },
|
||||
"filterConditionEqual": { "en": "is exactly" },
|
||||
"filterConditionNotEqual": { "en": "is not" },
|
||||
"filterConditionGreater": { "en": "is greater" },
|
||||
|
|
|
@ -73,6 +73,8 @@ class MenuFilter extends React.Component<Props, {}> {
|
|||
));
|
||||
|
||||
const Item = SortableElement((item: any) => {
|
||||
console.log(item);
|
||||
|
||||
const relation = item.relation;
|
||||
const conditionOptions = DataUtil.filterConditionsByType(relation.format);
|
||||
const refGet = (ref: any) => { this.refObj[item.id] = ref; };
|
||||
|
@ -261,7 +263,11 @@ class MenuFilter extends React.Component<Props, {}> {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<div className={cv.join(' ')}>{value}</div>
|
||||
{item.condition != I.FilterCondition.None ? (
|
||||
<div className={cv.join(' ')}>
|
||||
{value}
|
||||
</div>
|
||||
) : ''}
|
||||
|
||||
<Icon className="delete" onClick={(e: any) => { this.onDelete(e, item.id); }} />
|
||||
</form>
|
||||
|
@ -393,7 +399,7 @@ class MenuFilter extends React.Component<Props, {}> {
|
|||
|
||||
const first = relationOptions[0];
|
||||
const conditions = DataUtil.filterConditionsByType(first.format);
|
||||
const condition = conditions.length ? conditions[0].id : I.FilterCondition.Equal;
|
||||
const condition = conditions.length ? conditions[0].id : I.FilterCondition.None;
|
||||
|
||||
view.filters.push({
|
||||
relationKey: first.id,
|
||||
|
@ -461,7 +467,7 @@ class MenuFilter extends React.Component<Props, {}> {
|
|||
const relation = dbStore.getRelation(rootId, blockId, v);
|
||||
const conditions = DataUtil.filterConditionsByType(relation.format);
|
||||
|
||||
item.condition = conditions.length ? conditions[0].id : I.FilterCondition.Equal;
|
||||
item.condition = conditions.length ? conditions[0].id : I.FilterCondition.None;
|
||||
item.value = this.valueByType(relation.format);
|
||||
|
||||
view.filters = view.filters.filter((it: I.Filter, i: number) => {
|
||||
|
|
|
@ -175,9 +175,6 @@ class MenuViewEdit extends React.Component<Props, {}> {
|
|||
};
|
||||
|
||||
view.name = v;
|
||||
|
||||
window.clearTimeout(this.timeout);
|
||||
this.timeout = window.setTimeout(() => { this.save(); }, 500);
|
||||
};
|
||||
|
||||
save () {
|
||||
|
|
|
@ -154,11 +154,14 @@ class MenuViewList extends React.Component<Props> {
|
|||
const filters: I.Filter[] = [];
|
||||
|
||||
for (let relation of relations) {
|
||||
const conditions = DataUtil.filterConditionsByType(relation.format);
|
||||
if (relation.isHidden || !relation.isVisible) {
|
||||
continue;
|
||||
};
|
||||
|
||||
filters.push({
|
||||
relationKey: relation.relationKey,
|
||||
operator: I.FilterOperator.And,
|
||||
condition: conditions.length ? conditions[0].id : I.FilterCondition.Equal,
|
||||
condition: I.FilterCondition.None,
|
||||
value: null,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -31,19 +31,20 @@ export enum FilterOperator {
|
|||
};
|
||||
|
||||
export enum FilterCondition {
|
||||
Equal = 0,
|
||||
NotEqual = 1,
|
||||
Greater = 2,
|
||||
Less = 3,
|
||||
GreaterOrEqual = 4,
|
||||
LessOrEqual = 5,
|
||||
Like = 6,
|
||||
NotLike = 7,
|
||||
In = 8,
|
||||
NotIn = 9,
|
||||
Empty = 10,
|
||||
NotEmpty = 11,
|
||||
AllIn = 12,
|
||||
None = 0,
|
||||
Equal = 1,
|
||||
NotEqual = 2,
|
||||
Greater = 3,
|
||||
Less = 4,
|
||||
GreaterOrEqual = 5,
|
||||
LessOrEqual = 6,
|
||||
Like = 7,
|
||||
NotLike = 8,
|
||||
In = 9,
|
||||
NotIn = 10,
|
||||
Empty = 11,
|
||||
NotEmpty = 12,
|
||||
AllIn = 13,
|
||||
};
|
||||
|
||||
export interface Sort {
|
||||
|
|
|
@ -184,7 +184,9 @@ class DataUtil {
|
|||
};
|
||||
|
||||
filterConditionsByType (type: I.RelationType): any[] {
|
||||
let ret = [];
|
||||
let ret = [
|
||||
{ id: I.FilterCondition.None, name: translate('filterConditionNone') },
|
||||
];
|
||||
|
||||
switch (type) {
|
||||
case I.RelationType.ShortText:
|
||||
|
@ -192,47 +194,47 @@ class DataUtil {
|
|||
case I.RelationType.Url:
|
||||
case I.RelationType.Email:
|
||||
case I.RelationType.Phone:
|
||||
ret = [
|
||||
ret = ret.concat([
|
||||
{ id: I.FilterCondition.Equal, name: translate('filterConditionEqual') },
|
||||
{ id: I.FilterCondition.NotEqual, name: translate('filterConditionNotEqual') },
|
||||
{ id: I.FilterCondition.Like, name: translate('filterConditionLike') },
|
||||
{ id: I.FilterCondition.NotLike, name: translate('filterConditionNotLike') },
|
||||
{ id: I.FilterCondition.Empty, name: translate('filterConditionEmpty') },
|
||||
{ id: I.FilterCondition.NotEmpty, name: translate('filterConditionNotEmpty') },
|
||||
];
|
||||
]);
|
||||
break;
|
||||
|
||||
case I.RelationType.Object:
|
||||
case I.RelationType.Status:
|
||||
case I.RelationType.Tag:
|
||||
ret = [
|
||||
ret = ret.concat([
|
||||
{ id: I.FilterCondition.In, name: translate('filterConditionInArray') },
|
||||
{ id: I.FilterCondition.AllIn, name: translate('filterConditionAllIn') },
|
||||
{ id: I.FilterCondition.Equal, name: translate('filterConditionEqual') },
|
||||
{ id: I.FilterCondition.NotIn, name: translate('filterConditionNotInArray') },
|
||||
{ id: I.FilterCondition.Empty, name: translate('filterConditionEmpty') },
|
||||
{ id: I.FilterCondition.NotEmpty, name: translate('filterConditionNotEmpty') },
|
||||
];
|
||||
]);
|
||||
break;
|
||||
|
||||
case I.RelationType.Number:
|
||||
case I.RelationType.Date:
|
||||
ret = [
|
||||
ret = ret.concat([
|
||||
{ id: I.FilterCondition.Equal, name: '=' },
|
||||
{ id: I.FilterCondition.NotEqual, name: '≠' },
|
||||
{ id: I.FilterCondition.Greater, name: '>' },
|
||||
{ id: I.FilterCondition.Less, name: '<' },
|
||||
{ id: I.FilterCondition.GreaterOrEqual, name: '≥' },
|
||||
{ id: I.FilterCondition.LessOrEqual, name: '≤' },
|
||||
];
|
||||
]);
|
||||
break;
|
||||
|
||||
case I.RelationType.Checkbox:
|
||||
default:
|
||||
ret = [
|
||||
ret = ret.concat([
|
||||
{ id: I.FilterCondition.Equal, name: translate('filterConditionEqual') },
|
||||
{ id: I.FilterCondition.NotEqual, name: translate('filterConditionNotEqual') },
|
||||
];
|
||||
]);
|
||||
break;
|
||||
};
|
||||
return ret;
|
||||
|
|
|
@ -143,7 +143,7 @@ class Filter implements I.Filter {
|
|||
|
||||
relationKey: string = '';
|
||||
operator: I.FilterOperator = I.FilterOperator.And;
|
||||
condition: I.FilterCondition = I.FilterCondition.Equal;
|
||||
condition: I.FilterCondition = I.FilterCondition.None;
|
||||
value: any = {};
|
||||
|
||||
constructor (props: I.Filter) {
|
||||
|
@ -151,7 +151,7 @@ class Filter implements I.Filter {
|
|||
|
||||
self.relationKey = String(props.relationKey || '');
|
||||
self.operator = Number(props.operator) || I.FilterOperator.And;
|
||||
self.condition = Number(props.condition) || I.FilterCondition.Equal;
|
||||
self.condition = Number(props.condition) || I.FilterCondition.None;
|
||||
self.value = props.value;
|
||||
|
||||
decorate(self, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue