Browse Source

Minor improvement for param check

master
Radu Liviu Carjan 3 years ago
parent
commit
43cc07f80b
  1. 37
      public/js/app.js
  2. 2
      resources/js/app.ts
  3. 25
      resources/js/components/ProcessFile/ProcessFile.ts
  4. 4
      resources/js/components/ProcessFile/ProcessFile.vue

37
public/js/app.js

@ -3948,7 +3948,6 @@ var ProcessFile = /*#__PURE__*/function (_Vue) {
}, {
key: "createDiffPreview",
value: function createDiffPreview() {
// console.log('CREATING DIFF PREVIEW: ', this.processedFileContent);
this.processedFileContentPreview = this.processedFileContent;
var indexes = [];
@ -4002,11 +4001,35 @@ var ProcessFile = /*#__PURE__*/function (_Vue) {
return downloadOdt;
}()
}, {
key: "canRunSearchers",
value: function canRunSearchers() {
if (this.fileContent == '' || Object.keys(this.selectedSearchers).length === 0) {
return false;
}
for (var _i = 0, _Object$keys = Object.keys(this.selectedSearchers); _i < _Object$keys.length; _i++) {
var key = _Object$keys[_i];
var searcher = this.selectedSearchers[key];
if (!this.isValidParam(searcher.id, searcher.param)) {
return false;
}
}
return true;
}
/**
* Check if a param is valid or not.
*
* @param {string} paramId
* @param {string} paramType
* @returns {boolean}
*/
}, {
key: "isValidParam",
value: function isValidParam(paramId, paramType) {
console.log('PARAM: ', paramId, this.searchersOptions[paramId]);
if (paramType === 'required' && (this.searchersOptions[paramId] === '' || this.searchersOptions[paramId] === undefined)) {
return false;
}
@ -29270,9 +29293,7 @@ var render = function() {
attrs: {
label: "Run filters",
icon: "pi pi-play",
disabled:
_vm.fileContent == "" ||
Object.keys(_vm.selectedSearchers).length === 0
disabled: !_vm.canRunSearchers()
},
on: { click: _vm.runSearchers }
})
@ -29622,9 +29643,7 @@ var render = function() {
attrs: {
label: "Run filters",
icon: "pi pi-play",
disabled:
_vm.fileContent == "" ||
Object.keys(_vm.selectedSearchers).length === 0
disabled: !_vm.canRunSearchers()
},
on: {
click: function($event) {

2
resources/js/app.ts

@ -92,9 +92,7 @@ Vue.component('app-footer', AppFooter);
// Views
Vue.component('home', Home);
Vue.component('regex-create', RegexCreate);
Vue.component('searchers-index', SearchersIndex);
Vue.component('searchers-create', SearchersCreate);
Vue.component('searchers-show', SearchersShow);

25
resources/js/components/ProcessFile/ProcessFile.ts

@ -258,7 +258,6 @@ export default class ProcessFile extends Vue {
* Create the diff preview for the document
*/
private createDiffPreview() {
// console.log('CREATING DIFF PREVIEW: ', this.processedFileContent);
this.processedFileContentPreview = this.processedFileContent;
let indexes: Array<{ start: number; end: number }> = [];
@ -294,9 +293,29 @@ export default class ProcessFile extends Vue {
window.open(`${window.location.origin}/file/download/` + response.path);
}
private isValidParam(paramId: string, paramType: string): boolean {
private canRunSearchers(): boolean {
if (this.fileContent == '' || Object.keys(this.selectedSearchers).length === 0) {
return false;
}
console.log('PARAM: ', paramId, this.searchersOptions[paramId]);
for (let key of Object.keys(this.selectedSearchers)) {
const searcher = this.selectedSearchers[key];
if (!this.isValidParam(searcher.id, searcher.param)) {
return false;
}
}
return true;
}
/**
* Check if a param is valid or not.
*
* @param {string} paramId
* @param {string} paramType
* @returns {boolean}
*/
private isValidParam(paramId: string, paramType: string): boolean {
if (
paramType === 'required' &&
(this.searchersOptions[paramId] === '' || this.searchersOptions[paramId] === undefined)

4
resources/js/components/ProcessFile/ProcessFile.vue

@ -69,7 +69,7 @@
label="Run filters"
icon="pi pi-play"
class="p-button-success p-button-outlined p-button-sm"
:disabled="fileContent == '' || Object.keys(selectedSearchers).length === 0"
:disabled="!canRunSearchers()"
@click="runSearchers"/>
</template>
</Toolbar>
@ -226,7 +226,7 @@
label="Run filters"
icon="pi pi-play"
class="p-button-success p-button-sm"
:disabled="fileContent == '' || Object.keys(selectedSearchers).length === 0"
:disabled="!canRunSearchers()"
@click="toggleSearchersSidebar(); runSearchers()"/>
</template>
</DataTable>

Loading…
Cancel
Save