-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: create component modal for multiple uses * feat: create component modal for multiple uses * feat: #96 create menu for search * feat: #96 create menu for search * feat: merge * feat: doing interactive menu Co-authored-by: André Gava <[email protected]>
- Loading branch information
1 parent
6c556f8
commit 2b42c42
Showing
15 changed files
with
359 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Person from './Person'; | ||
import Title from './Title'; | ||
import {AdapterBaseProps} from '../../electron/database/adapter/AdapterBase'; | ||
import { SearchSource } from '../util/DefaultEntities'; | ||
|
||
interface Product { | ||
[key: string]: Person | Title; | ||
} | ||
|
||
class BehaviourFactory { | ||
static readonly factories: Product = { | ||
Person: new Person(), | ||
Title: new Title(), | ||
}; | ||
|
||
static make(item: AdapterBaseProps): SearchSource { | ||
const classElement = this.factories[item.handler]; | ||
return classElement.execute(item); | ||
} | ||
} | ||
|
||
export default BehaviourFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FaPlus, FaUser, FaBook, FaHandshake } from 'react-icons/fa'; | ||
import { FiBook } from 'react-icons/fi'; | ||
import { IconBaseProps } from 'react-icons'; | ||
|
||
interface Product { | ||
[key: string]: React.ComponentType<IconBaseProps>; | ||
} | ||
|
||
class IconFactory { | ||
static readonly icons: Product = { | ||
FiBook: FiBook, | ||
FaPlus: FaPlus, | ||
FaUser: FaUser, | ||
FaBook: FaBook, | ||
FaHandshake: FaHandshake, | ||
}; | ||
|
||
static icon(param: string): React.ComponentType<IconBaseProps> { | ||
return this.icons[param]; | ||
} | ||
} | ||
|
||
export default IconFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { trigger } from '../util/EventHandler'; | ||
import { AppEvent } from '../../common/AppEvent'; | ||
import { Actions } from '../../common/Actions'; | ||
import IconFactory from './IconFactory'; | ||
import {AdapterBaseProps} from '../../electron/database/adapter/AdapterBase'; | ||
import { SearchSource } from '../util/DefaultEntities'; | ||
|
||
class Person { | ||
execute(item: AdapterBaseProps): SearchSource { | ||
const icon = IconFactory.icon(item.icon); | ||
const iconAction = IconFactory.icon(item.iconAction); | ||
|
||
const newItem = { | ||
name: item.name, | ||
label: item.label, | ||
complement: item.complement, | ||
icon: icon, | ||
iconColor: item.iconColor, | ||
iconAction: iconAction, | ||
handler: { | ||
onClick: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.personTab, { | ||
action: Actions.read, | ||
value: item.item, | ||
}); | ||
}, | ||
onPress: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.personTab, { | ||
action: Actions.read, | ||
value: item.item, | ||
}); | ||
}, | ||
}, | ||
action: { | ||
onClick: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.borrowTab, { | ||
action: Actions.create, | ||
value: item.item, | ||
}); | ||
}, | ||
onPress: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.borrowTab, { | ||
action: Actions.create, | ||
value: item.item, | ||
}); | ||
}, | ||
}, | ||
}; | ||
return newItem; | ||
} | ||
} | ||
|
||
export default Person; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { trigger } from '../util/EventHandler'; | ||
import { AppEvent } from '../../common/AppEvent'; | ||
import { Actions } from '../../common/Actions'; | ||
import IconFactory from './IconFactory'; | ||
import {AdapterBaseProps} from '../../electron/database/adapter/AdapterBase'; | ||
import { SearchSource } from '../util/DefaultEntities'; | ||
|
||
class Title { | ||
execute(item: AdapterBaseProps): SearchSource { | ||
const icon = IconFactory.icon(item.icon); | ||
const iconAction = IconFactory.icon(item.iconAction); | ||
const newItem = { | ||
name: item.name, | ||
label: item.label, | ||
complement: item.complement, | ||
icon: icon, | ||
iconColor: item.iconColor, | ||
iconAction: iconAction, | ||
handler: { | ||
onClick: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.titleTab, { | ||
action: Actions.read, | ||
value: item.item, | ||
}); | ||
}, | ||
onPress: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.titleTab, { | ||
action: Actions.read, | ||
value: item.item, | ||
}); | ||
}, | ||
}, | ||
action: { | ||
onClick: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.borrowTab, { | ||
action: Actions.create, | ||
value: item.item, | ||
}); | ||
}, | ||
onPress: (): void => { | ||
trigger(AppEvent.quickSearch); | ||
trigger(AppEvent.borrowTab, { | ||
action: Actions.create, | ||
value: item.item, | ||
}); | ||
}, | ||
}, | ||
}; | ||
return newItem; | ||
} | ||
} | ||
|
||
export default Title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Title } from '../models/Title.schema'; | ||
import { User } from '../models/User.schema'; | ||
|
||
export type AdapterBaseProps = { | ||
name: string; | ||
label: string; | ||
complement?: string; | ||
icon: string; | ||
iconColor: string; | ||
iconAction: string; | ||
handler: string; | ||
action: string; | ||
item: Title | User; | ||
}; | ||
|
||
interface BaseAdapterContract { | ||
defineData(dataFromRepository: Title[] | User[]): Promise<AdapterBaseProps[]>; | ||
} | ||
|
||
export default class AdapterBase implements BaseAdapterContract { | ||
defineData( | ||
dataFromRepository: Title[] | User[] | ||
): Promise<AdapterBaseProps[]> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Title } from '../models/Title.schema'; | ||
import { User } from '../models/User.schema'; | ||
import AdapterBase, { AdapterBaseProps } from './AdapterBase'; | ||
|
||
export default class PersonAdapter implements AdapterBase { | ||
public async defineData( | ||
dataFromRepository: Title[] | User[] | ||
): Promise<AdapterBaseProps[]> { | ||
try { | ||
const data = dataFromRepository.map((item: Title | User) => { | ||
const processedItem = { | ||
name: item.name, | ||
label: item.name, | ||
complement: item.name, | ||
icon: 'FaUser', | ||
iconColor: '#ff78f7', | ||
iconAction: 'FaHandshake', | ||
handler: 'Person', | ||
action: 'Person', | ||
item: item, | ||
}; | ||
|
||
return processedItem; | ||
}); | ||
return data; | ||
} catch (err) { | ||
console.log(err); | ||
throw err; | ||
} | ||
} | ||
} |
Oops, something went wrong.