Skip to content

Commit

Permalink
Merge pull request #180 from openimis/develop
Browse files Browse the repository at this point in the history
MERGING RELEASE branches
  • Loading branch information
delcroip authored Dec 6, 2023
2 parents 82bf65d + dda77e8 commit f8ff6f9
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 71 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ None
- `AmountInput.currencyPosition`: position of the currency for the AmountInput. Choices are `start` and `end` (default: `start`)
- `menuLeft`: position menu in the Drawer component on the left site of the application
- `calendarSwitch`: enable calendar switcher toggle on the navbar of the webpage. Currently supports nepali calendar. Default false.
- `secondCalendarFormatting`: formatting options for second calendar, default: "DD-MM-YYYY"
- `secondCalendarFormattingLang`: formatting language for second calendar, default: "en"
- `redirectToCoreMISConfluenceUrl` clicking on questionmark icon will take you to coreMIS confluence page, default openIMIS manual
- `secondCalendarFormatting`: formatting options for second calendar (both picker and display), default: "DD-MM-YYYY"
- `secondCalendarFormattingLang`: formatting language for second calendar (when displayed as saved data, not in pickers), default: "en"
- `redirectToCoreMISConfluenceUrl`: clicking on questionmark icon will take you to coreMIS confluence page, default openIMIS manual
- `App.economicUnitConfig`:
In the specified configuration, when the parameter is set to __true__, it necessitates that users are associated with an Economic Unit. If a user lacks this association, a modal will be displayed to prompt them to establish it. Until the user is linked to a unit, their only authorized action is to log out. The default configuration is __false__.
- `LogoutButton.showMPassProvider`: when activated, routes the user to the saml logout page for secure session termination
- `LoginPage.showMPassProvider`: redirects users to the saml login page, facilitating access to mPass-protected resources
- `secondCalendarType`: type of secondary calendar picker (if enabled), default "nepali"
- `secondCalendarLocale`: locale for secondary calendar picker (if enabled), default "nepali_en"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"src"
],
"dependencies": {
"@sbmdkl/nepali-datepicker-reactjs": "^1.2.1",
"history": "^5.2.0",
"nepali-date-converter": "^3.3.1",
"react-multi-date-picker": "^4.3.3",
"react-router": "^5.2.1",
"react-router-dom": "^5.2.1"
}
Expand Down
177 changes: 177 additions & 0 deletions src/calendars/NepalCalendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
const nepali = {
name: "nepali",
startYear: 1,
yearLength: 365,
epoch: 1701212,
century: 20,
weekStartDayIndex: 1,
getMonthLengths(year) {
if (year < 1970) return nepaliMonthsDictionary["1970"];
else if (year > 2099) return nepaliMonthsDictionary["2099"];
else return nepaliMonthsDictionary[parseInt(year)];
},
isLeap(year) {
// workaround needed because of things hardcoded in library
return year;
},
getLeaps(currentYear) {
return [];
},
getDayOfYear({ year, month, day }) {
let monthLengths = this.getMonthLengths(year);

for (let i = 0; i < month.index; i++) {
day += monthLengths[i];
}

return day;
},
getAllDays(date) {
const { year } = date;

return this.yearLength * (year - 1) + this.getDayOfYear(date);
},
leapsLength(year) {
return 0;
},
guessYear(days, currentYear) {
let year = ~~(days / 365.24);

return year + (currentYear > 0 ? 1 : -1);
},
};

// based on code from legacy version
const nepaliMonthsDictionary = {
"1970": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1971": [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
"1972": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"1973": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], //1973
"1974": [31, 31, 32, 30, 31, 31, 30, 29, 30, 29, 30, 30],
"1975": [31, 31, 32, 32, 30, 31, 30, 29, 30, 29, 30, 30],
"1976": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"1977": [31, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
"1978": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1979": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"1980": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"1981": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"1982": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1983": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"1984": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"1985": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"1986": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1987": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"1988": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"1989": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"1990": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1991": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"1992": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"1993": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"1994": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1995": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"1996": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"1997": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1998": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"1999": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2000": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], //2000
"2001": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], //2001
"2002": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2003": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2004": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2005": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2006": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2007": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2008": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
"2009": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2010": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2011": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2012": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"2013": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2014": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2015": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2016": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"2017": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2018": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2019": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2020": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2021": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2022": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"2023": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2024": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2025": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2026": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2027": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2028": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2029": [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
"2030": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2031": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2032": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2033": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2034": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2035": [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
"2036": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2037": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2038": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2039": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"2040": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2041": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2042": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2043": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"2044": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2045": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2046": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2047": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2048": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2049": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"2050": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2051": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2052": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2053": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"2054": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2055": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2056": [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
"2057": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2058": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2059": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2060": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2061": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2062": [30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
"2063": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2064": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2065": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2066": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
"2067": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2068": [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2069": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
"2070": [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
"2071": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], //2071
"2072": [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], //2072
"2073": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], //2073
"2074": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2075": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2076": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"2077": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
"2078": [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
"2079": [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
"2080": [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
"2081": [31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2082": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2083": [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
"2084": [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
"2085": [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
"2086": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2087": [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
"2088": [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
"2089": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2090": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], //2090
"2091": [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
"2092": [30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2093": [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2094": [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
"2095": [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30],
"2096": [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
"2097": [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
"2098": [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31],
"2099": [31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], //2099
};
export default nepali;
33 changes: 33 additions & 0 deletions src/calendars/NepaliLocaleEn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const nepali_en = {
name: "nepali_en",
months: [
["Baishakh", "Baishakh"],
["Jestha", "Jestha"],
["Ashadh", "Ashadh"],
["Shrawan", "Shrawan"],
["Bhadra", "Bhadra"],
["Ashwin", "Ashwin"],
["Kartik", "Kartik"],
["Mangsir", "Mangsir"],
["Poush", "Poush"],
["Magh", "Magh"],
["Falgun", "Falgun"],
["Chaitra", "Chaitra"],
],
weekDays: [
["Saturday", "Sat"],
["Sunday", "Sun"],
["Monday", "Mon"],
["Tuesday", "Tue"],
["Wednesday", "Wed"],
["Thursday", "Thu"],
["Friday", "Fri"],
],
digits: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
meridiems: [
["AM", "am"],
["PM", "pm"],
],
};

export default nepali_en;
33 changes: 33 additions & 0 deletions src/calendars/NepaliLocaleNp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const nepali_np = {
name: "nepali_np",
months: [
["Baishakh", "Baishakh"],
["Jestha", "Jestha"],
["Ashadh", "Ashadh"],
["Shrawan", "Shrawan"],
["Bhadra", "Bhadra"],
["Ashwin", "Ashwin"],
["Kartik", "Kartik"],
["Mangsir", "Mangsir"],
["Poush", "Poush"],
["Magh", "Magh"],
["Falgun", "Falgun"],
["Chaitra", "Chaitra"],
],
weekDays: [
["Saturday", "Sat"],
["Sunday", "Sun"],
["Monday", "Mon"],
["Tuesday", "Tue"],
["Wednesday", "Wed"],
["Thursday", "Thu"],
["Friday", "Fri"],
],
digits: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
meridiems: [
["AM", "am"],
["PM", "pm"],
],
};

export default nepali_np;
7 changes: 2 additions & 5 deletions src/components/inputs/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const Autocomplete = (props) => {
setCurrentString,
multiple = false,
renderInput,
noOptionsText,
} = props;
const modulesManager = useModulesManager();
const minCharLookup = modulesManager.getConf("fe-admin", "usersMinCharLookup", 2);
const { formatMessage } = useTranslations("core.Autocomplete", modulesManager);
const [open, setOpen] = useState(false);
const [resetKey, setResetKey] = useState(Date.now());
const shouldBeSelected = required && options.length === 1;

const handleInputChange = useDebounceCb((searchString) => {
setCurrentString && setCurrentString(searchString);
Expand All @@ -69,14 +69,11 @@ const Autocomplete = (props) => {
setResetKey(Date.now());
}, [value]);

useEffect(() => {
if (shouldBeSelected) onChange(options[0]);
}, [options?.length])

return (
<MuiAutocomplete
key={resetKey}
fullWidth={fullWidth}
noOptionsText={noOptionsText}
className={className}
style={{ minWidth }}
loadingText={formatMessage("loadingText")}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Table from "./components/generics/Table";
import SearcherExport from "./components/generics/SearcherExport";
import Searcher from "./components/generics/Searcher";
import SearcherPane from "./components/generics/SearcherPane";
import DatePicker from "./pickers/DatePicker";
import openIMISDatePicker from "./pickers/DatePicker";
import Picker from "./components/generics/Picker";
import ConstantBasedPicker from "./components/generics/ConstantBasedPicker";
import CustomFilterFieldStatusPicker from "./pickers/CustomFilterFieldStatusPicker";
Expand Down Expand Up @@ -192,7 +192,7 @@ const DEFAULT_CONFIG = {

export const CoreModule = (cfg) => {
let def = { ...DEFAULT_CONFIG };
def.refs.push({ key: "core.DatePicker", ref: DatePicker });
def.refs.push({ key: "core.DatePicker", ref: openIMISDatePicker });
return { ...def, ...cfg };
};

Expand Down
Loading

0 comments on commit f8ff6f9

Please sign in to comment.