Skip to content

Commit

Permalink
INTERMediator.clearCondition method clears page number of pagination.
Browse files Browse the repository at this point in the history
  • Loading branch information
msyk committed Feb 5, 2024
1 parent ca35325 commit 9b25b88
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 89 deletions.
9 changes: 6 additions & 3 deletions dist-docs/change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Please check: https://github.com/INTER-Mediator/INTER-Mediator
Also the Migration Guide (Japanese) might be informative:
https://inter-mediator.info/ja/for-developers/migration.html

Ver.12 (In Development)
Ver.13 (In Development)

Ver.12 (Februrary xx, 2024)
- PHP Ver.7.4 is the minimum version.
- Type description added to most PHP code. The Export class and the OperationLogExtension class are added types, and
your inherited class has to add them. The extending-class based methods didn't add types.
Expand All @@ -19,9 +21,10 @@ Ver.12 (In Development)
- INTERMediator.prepareToScrollBack and scrollBack methods are for retrieving scroll position on backing from detail.
samples/Sample_forDebugging/longlist.html is a sample of these methods.
- On query condition, the value surrounded by @ is handled with the field name. For example, {field: "a", value: "b"}
generates the where clause `a` = "b", othewise {field: "a", value: "@b@"} generates `a` = `b`.
generates the where clause `a` = "b", otherwise {field: "a", value: "@b@"} generates `a` = `b`.
- Forever booted the service server, but it replaced with nodaemon. $stopSSEveryQuit in params.php doesn't work anymore.
- /spec/Manual-Tests/End-to-End-Test.md is added, and it records the result of manual end-to-end tests.
- INTERMediator.clearCondition method clears page number of pagination. Also no parameter clears all conditions.
- [INFO] In the Ver.9, the following change was made with compatibility. The setUpdatedRecord method doesn't call the
setDataToUpdatedRecord anymore.
- (Ver.9) The setUpdatedRecord method in database classes renamed to setDataToUpdatedRecord. For the compatibility,
Expand All @@ -30,7 +33,7 @@ Ver.12 (In Development)
- [BUG FIX] The data-im="_@condition:..." way with numeric field and the "match" operator didn't expand the condition
clause with '%term%' value. As far as PostgreSQL goes, the casting to text is automatically applied it.
- [BUG FIX] The INPUT[type=datetime-local] elements reported someone edit your modified data, but it was new record data
after updateing is not adjusted to UTC correctly. Also INTERMediatorLib.dateTimeStringISO and some method returns
after updating is not adjusted to UTC correctly. Also INTERMediatorLib.dateTimeStringISO and some method returns
browser local date and time.
- [BUG FIX] Fix an error when using PHP 8.3.0 or later / PHP 8.1.25 / PHP 8.2.12 and $appLocale is undefined in
params.php.
Expand Down
7 changes: 7 additions & 0 deletions samples/E2E-Test/SearchPage/searching_MySQL.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
break;
}
}

function clearConditions() {
IMLibLocalContext.clearAllConditions()
INTERMediator.clearCondition('postalcode')
INTERMediator.constructMain(IMLibContextPool.contextFromName('postalcode'))
}
</script>
</head>
<body>
Expand All @@ -87,6 +93,7 @@
<option value="1000000">1000000</option>
</select>
<button id="_im_test_button_search" data-im="_@update:postalcode">Search</button>
<button onclick="clearConditions()">Clear</button>
</th>
</tr>
<tr>
Expand Down
7 changes: 7 additions & 0 deletions samples/E2E-Test/SearchPage/searching_PostgreSQL.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
break;
}
}

function clearConditions() {
IMLibLocalContext.clearAllConditions()
INTERMediator.clearCondition('postalcode')
INTERMediator.constructMain(IMLibContextPool.contextFromName('postalcode'))
}
</script>
</head>
<body>
Expand All @@ -87,6 +93,7 @@
<option value="1000000">1000000</option>
</select>
<button id="_im_test_button_search" data-im="_@update:postalcode">Search</button>
<button onclick="clearConditions()">Clear</button>
</th>
</tr>
<tr>
Expand Down
7 changes: 7 additions & 0 deletions samples/E2E-Test/SearchPage/searching_SQLite.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
break;
}
}

function clearConditions() {
IMLibLocalContext.clearAllConditions()
INTERMediator.clearCondition('postalcode-search')
INTERMediator.constructMain(IMLibContextPool.contextFromName('postalcode-search'))
}
</script>
</head>
<body>
Expand Down Expand Up @@ -90,6 +96,7 @@
<option value="1000000">1000000</option>
</select>
<button id="_im_test_button_search" data-im="_@update:postalcode-search">Search</button>
<button onclick="clearConditions()">Clear</button>
</th>
</tr>
<tr>
Expand Down
182 changes: 96 additions & 86 deletions src/js/INTER-Mediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1961,29 +1961,30 @@ const INTERMediator = {
IMLibLocalContext.archive()
},

clearCondition: (contextName, label) => {
'use strict'
let value = INTERMediator.additionalCondition
if (!value) {
value = {}
}
if (typeof label === 'undefined') {
if (value[contextName]) {
delete value[contextName]
INTERMediator.additionalCondition = value
IMLibLocalContext.archive()
}
} else {
clearCondition: (contextName = false, label = false) => {
if(contextName) {
let value = INTERMediator.additionalCondition ?? {}
if (value[contextName]) {
for (let i = 0; i < value[contextName].length; i++) {
if (value[contextName][i].label === label) {
value[contextName].splice(i, 1)
i--
if (!label) {
delete value[contextName]
} else {
for (let i = 0; i < value[contextName].length; i++) {
if (value[contextName][i].label === label) {
value[contextName].splice(i, 1)
i--
}
}
}
INTERMediator.additionalCondition = value
IMLibLocalContext.archive()
}
if (INTERMediatorOnPage.getContextInfo(contextName).paging) {
INTERMediator.startFrom = 0
}
} else { // In case of no parameter.
INTERMediator.additionalCondition = {}
IMLibLocalContext.archive()
INTERMediator.startFrom = 0
}
},

Expand All @@ -2009,78 +2010,84 @@ const INTERMediator = {
}
},

setRecordLimit: (contextName, limit) => {
'use strict'
const value = INTERMediator.recordLimit
value[contextName] = limit
INTERMediator.recordLimit = value
IMLibLocalContext.archive()
},

clearRecordLimit: (contextName) => {
'use strict'
const value = INTERMediator.recordLimit
if (value[contextName]) {
delete value[contextName]
setRecordLimit:
(contextName, limit) => {
'use strict'
const value = INTERMediator.recordLimit
value[contextName] = limit
INTERMediator.recordLimit = value
IMLibLocalContext.archive()
}
},
},

setRecordStart: (contextName, limit) => {
'use strict'
const value = INTERMediator.recordStart
value[contextName] = limit
INTERMediator.recordStart = value
IMLibLocalContext.archive()
},
clearRecordLimit:
(contextName) => {
'use strict'
const value = INTERMediator.recordLimit
if (value[contextName]) {
delete value[contextName]
INTERMediator.recordLimit = value
IMLibLocalContext.archive()
}
},

clearRecordStart: (contextName) => {
'use strict'
const value = INTERMediator.recordStart
if (value[contextName]) {
delete value[contextName]
setRecordStart:
(contextName, limit) => {
'use strict'
const value = INTERMediator.recordStart
value[contextName] = limit
INTERMediator.recordStart = value
IMLibLocalContext.archive()
}
},
},

localizing: () => {
const targetNodes = document.querySelectorAll("*[data-im-locale]");
for (const node of targetNodes) {
const localeValue = node.getAttribute("data-im-locale")
const bindValue = node.getAttribute("data-im")
if (!bindValue) {
const value = INTERMediator.getLocalizedString(localeValue)
if (value) { // If the value is null, do nothing anyway.
const bros = node.childNodes
for (const item of bros) {
if (item.nodeType === Node.TEXT_NODE) {
node.removeChild(item)
clearRecordStart:
(contextName) => {
'use strict'
const value = INTERMediator.recordStart
if (value[contextName]) {
delete value[contextName]
INTERMediator.recordStart = value
IMLibLocalContext.archive()
}
},

localizing:
() => {
const targetNodes = document.querySelectorAll("*[data-im-locale]");
for (const node of targetNodes) {
const localeValue = node.getAttribute("data-im-locale")
const bindValue = node.getAttribute("data-im")
if (!bindValue) {
const value = INTERMediator.getLocalizedString(localeValue)
if (value) { // If the value is null, do nothing anyway.
const bros = node.childNodes
for (const item of bros) {
if (item.nodeType === Node.TEXT_NODE) {
node.removeChild(item)
}
}
node.appendChild(document.createTextNode(value))
}
node.appendChild(document.createTextNode(value))
}
}
}
},
},

getLocalizedString: (localeValue) => {
const terms = INTERMediatorOnPage.getTerms()
if (!terms || !localeValue) {
return null;
}
const localeKey = localeValue.split('|')
let value = terms
for (const key of localeKey) {
if (!value[key]) {
value = null
break;
}
value = value[key]
}
return value
},
getLocalizedString:
(localeValue) => {
const terms = INTERMediatorOnPage.getTerms()
if (!terms || !localeValue) {
return null;
}
const localeKey = localeValue.split('|')
let value = terms
for (const key of localeKey) {
if (!value[key]) {
value = null
break;
}
value = value[key]
}
return value
},

ignoreDataInContext(contextName, flag = true) {
const check = INTERMediator.ignoringDataContexts.indexOf(contextName)
Expand All @@ -2093,22 +2100,25 @@ const INTERMediator = {
INTERMediator.ignoringDataContexts.splice(check, 1)
}
}
},
}
,

/* Compatibility for previous version. These methos are defined here ever.
* Now these are defined in INTERMediatorLog object. */
flushMessage: () => {
'use strict'
INTERMediatorLog.flushMessage()
},
setErrorMessage: (ex, moreMessage) => {
'use strict'
INTERMediatorLog.setErrorMessage(ex, moreMessage)
},
setDebugMessage: (message, level) => {
'use strict'
INTERMediatorLog.setDebugMessage(message, level)
}
setErrorMessage:
(ex, moreMessage) => {
'use strict'
INTERMediatorLog.setErrorMessage(ex, moreMessage)
},
setDebugMessage:
(message, level) => {
'use strict'
INTERMediatorLog.setDebugMessage(message, level)
}
}

// @@IM@@IgnoringRestOfFile
Expand Down

0 comments on commit 9b25b88

Please sign in to comment.